From patchwork Tue Jan 16 15:01:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 124728 Delivered-To: patch@linaro.org Received: by 10.46.64.148 with SMTP id r20csp1042496lje; Tue, 16 Jan 2018 07:02:16 -0800 (PST) X-Google-Smtp-Source: ACJfBot6ANyOvphj9Um1559s1MTc0yyB8OqeleIN36kRjtA8z9EjCztIhckSZuXP5RKK3Xd732pb X-Received: by 10.84.237.9 with SMTP id s9mr22443722plk.176.1516114936353; Tue, 16 Jan 2018 07:02:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516114936; cv=none; d=google.com; s=arc-20160816; b=XCQp2F+ZrK0oPxW23qlLxi4NoRfVD9PQKmTxCCERHND0gYNOdh6m7/vlagrlKLVf2L PffaqOppptkK4hygwfivhdWYpgV4tqOTzArJS9dzR9NNpqPUtuitoe8yu/mOANg7PHzt wJyIthJuRKb7FlPcHkZ+09c+04rlyLxJjIAJ/BlSXzD6j8M716rNv15D3W0i736qWFXg 12ZyFH/uOYAgqTITgEUQnTXL0kWu7k/BRS9JtPYO55pW94ofJjwFjL7ZWFLjEtejRz1B nb1iJMSaEpo+3BnwWJ6QVNQGlDjpqKpLQmEVMkP/8Fdoi1pBMHg6YySy9X8lH6VeiYug yX5A== 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=B/gS4wM/JNAlI2qPy7RlqY0oOOcggwP1MYAdqYmMBNg=; b=VbQAysSqX7U1gHBelrQhds59Xo5Bv6jZn3jX1BMzjYMWEXy6lkoHlt0lIkLsDM++IA DcWPVnLlvMoE14ff92ClqlM8X8hkCO840zP8cBd1PeXpT54yrM+7cT5mi/hFskwWTt/H cJXdDXKsBNwmAShr97Q6psCDD3Fe8+sukpt6UYRFbFY7ctk3/zhp7HSY/dmrCKN/wJAk vZrqkc8XeKatRuEply8RFoTKj4FFnhqnZmRngUdyC8ZCA8XTQom/F5f7f3C/ZeLbL+LH W7czBVXgZxwMdxYc1fM9tvD10vaAxs1zdkzDWyMRBGgcXhABL5AVc/mxMqaJlG9t5TqD SLQQ== 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 c3si2134028plr.495.2018.01.16.07.02.16; Tue, 16 Jan 2018 07:02:16 -0800 (PST) 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 S1751368AbeAPPCP (ORCPT + 28 others); Tue, 16 Jan 2018 10:02:15 -0500 Received: from mout.kundenserver.de ([217.72.192.74]:64866 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750790AbeAPPCM (ORCPT ); Tue, 16 Jan 2018 10:02:12 -0500 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue105 [212.227.15.145]) with ESMTPA (Nemesis) id 0MC1E8-1ekIR11u9Q-008uVw; Tue, 16 Jan 2018 16:01:55 +0100 From: Arnd Bergmann To: Jens Axboe Cc: Arnd Bergmann , Tejun Heo , Shaohua Li , linux-kernel@vger.kernel.org Subject: [PATCH] [RESEND] blkcg: simplify statistic accumulation code Date: Tue, 16 Jan 2018 16:01:36 +0100 Message-Id: <20180116150154.2538110-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V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.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") Acked-by: Tejun Heo Signed-off-by: Arnd Bergmann --- Sent this original on Sep 15, got an Ack but it was never picked up. Jens, could you take this through the block tree? --- include/linux/blk-cgroup.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) -- 2.9.0 diff --git a/include/linux/blk-cgroup.h b/include/linux/blk-cgroup.h index e9825ff57b15..69bea82ebeb1 100644 --- a/include/linux/blk-cgroup.h +++ b/include/linux/blk-cgroup.h @@ -660,12 +660,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]); }