From patchwork Fri Sep 15 19:36:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 112749 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp983574qgf; Fri, 15 Sep 2017 12:37:11 -0700 (PDT) X-Google-Smtp-Source: ADKCNb4Cj89TFMjtsPI/ZJFf4aLdZLMz9KqnQt3qA8QCDpUH4URiTnOUdfEdmK6hxgDDK1NyzLtX X-Received: by 10.99.179.66 with SMTP id x2mr24889149pgt.336.1505504230933; Fri, 15 Sep 2017 12:37:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505504230; cv=none; d=google.com; s=arc-20160816; b=kSj75quP3nrBY0jBgWXCPCJeWK/zkMUHLw2PPUWq/ozpXAfqjMVtndssk/mXXi2azZ FTXtK/9MKizP3c7aCYbHL1vfHaaOUComb2iKDdPK+eY/eux7VcnHP+Q3G5qDhKoNzaqC zudU2nZDRsl2ng84JxlUeev7PwYy+fx3Km56KprXSxbdhbdOpOtmtn1DVCudlaeahywk a/+Ke5Nlgj0MNlKNeJUK/QgAWDH74QIr6crAyG+GxwGWKvs7z3CN8hR7GHhJD4tveIaE CcTw/4ZTfA4rpPZGDo9OFia2sOX/uSfosOdiBOgEWSEoYCtZ7LnHTsq13tk33ddkrzsn 4uyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=aJi/DbGvrKT5EFteQ0XArnJW5qskVrGsxZkiYMuvKog=; b=CQZRNofY/+LVUn7EGR5OKOa72UTjy/dYJt/+OT4bM6IpMSTkf18QiaTwh6oc/EFhMr qkwFI9hiq3Fy5MRTA2aDKmgNwE6urSOH3z81fiKMwU765Q1didIiDl8XTyJt79hjXH8r kriDnggt5Z67iI3LYcmrUFpSH1V/GQ2bEGlOnHrT9LFkCXk11FIxdddY8IMukY9qD1cK LmOrsj091vE64d/+7DC3UWUq03mX8ZoC/3BnwfA/Jb/6mZobB9fxWd8Rae9WhrVcixuW RTMdyRFbyPoF6hUo25poqwM7/QOI4nrBPXltjyQUme8VDwSg2crHm7z67Saqtbw9YoKX p3Cg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b6si1129743plm.659.2017.09.15.12.37.10; Fri, 15 Sep 2017 12:37:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751898AbdIOThH (ORCPT + 26 others); Fri, 15 Sep 2017 15:37:07 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:53212 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751633AbdIOThG (ORCPT ); Fri, 15 Sep 2017 15:37:06 -0400 Received: from wuerfel.lan ([95.208.190.237]) by mrelayeu.kundenserver.de (mreue102 [212.227.15.145]) with ESMTPA (Nemesis) id 0MY6a0-1dxONu2VbE-00UtPK; Fri, 15 Sep 2017 21:36:50 +0200 From: Arnd Bergmann To: Tejun Heo Cc: Arnd Bergmann , Jens Axboe , Tahsin Erdogan , Bart Van Assche , Shaohua Li , Nikolay Borisov , linux-kernel@vger.kernel.org Subject: [PATCH] blkcg: simplify statistic accumulation code Date: Fri, 15 Sep 2017 21:36:21 +0200 Message-Id: <20170915193647.1102621-1-arnd@arndb.de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2w2KzD5SHTfXffbgnjG/kCTBsQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some older compilers (gcc-4.4 through 4.6 in particular) struggle with the way that blkg_rwstat_read() returns a structure, leading to excessive stack usage and rather inefficient code: block/blk-cgroup.c: In function 'blkg_destroy': block/blk-cgroup.c:354:1: error: the frame size of 1296 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] block/cfq-iosched.c: In function 'cfqg_stats_add_aux': block/cfq-iosched.c:753:1: error: the frame size of 1928 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] block/bfq-cgroup.c: In function 'bfqg_stats_add_aux': block/bfq-cgroup.c:299:1: error: the frame size of 1928 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] I also notice that there is no point in using atomic accesses for the local variables, so storing the temporaries in simple 'u64' variables not only avoids the stack usage on older compilers but also improves the object code on modern versions. Fixes: e6269c445467 ("blkcg: add blkg_[rw]stat->aux_cnt and replace cfq_group->dead_stats with it") Signed-off-by: Arnd Bergmann --- include/linux/blk-cgroup.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) -- 2.9.0 Acked-by: Tejun Heo diff --git a/include/linux/blk-cgroup.h b/include/linux/blk-cgroup.h index 9d92153dd856..2f1ff739ea52 100644 --- a/include/linux/blk-cgroup.h +++ b/include/linux/blk-cgroup.h @@ -664,12 +664,14 @@ static inline void blkg_rwstat_reset(struct blkg_rwstat *rwstat) static inline void blkg_rwstat_add_aux(struct blkg_rwstat *to, struct blkg_rwstat *from) { - struct blkg_rwstat v = blkg_rwstat_read(from); + u64 sum[BLKG_RWSTAT_NR]; int i; for (i = 0; i < BLKG_RWSTAT_NR; i++) - atomic64_add(atomic64_read(&v.aux_cnt[i]) + - atomic64_read(&from->aux_cnt[i]), + sum[i] = percpu_counter_sum_positive(&from->cpu_cnt[i]); + + for (i = 0; i < BLKG_RWSTAT_NR; i++) + atomic64_add(sum[i] + atomic64_read(&from->aux_cnt[i]), &to->aux_cnt[i]); }