Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp2778422rwi; Fri, 28 Oct 2022 11:05:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4d0frRYntHjofrAE2jNljIMm7i/EpQUInofD4umt0ltB+DKmQfoUv7KcJGDH+53e6K1LkC X-Received: by 2002:a05:6402:d62:b0:460:42c8:fc6d with SMTP id ec34-20020a0564020d6200b0046042c8fc6dmr677850edb.182.1666980323761; Fri, 28 Oct 2022 11:05:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666980323; cv=none; d=google.com; s=arc-20160816; b=X2DbTdY22Lj6Vtebo6H1xqBIZd+vEHQUihm5TplVK5qjhUPAHDh9ePLs5J+VNpVhNL QfSzNOLDB+kx4ndjHjP+QhL4hy7AE+pWoBejEANBqHYAWdvDlioJGx3+TwXcYz4qD2dn 4jaFAhy2TX2JX5tePsBO+KfPubgI1BszIcvVaN0kTcpMNEyYBoDiptaCpVBg2NRV2aUw ALzW7B+o6EXJpexfKPi2XJdTk71UGW60jRpbZ756Y9Y7L/9fEMFGK/n6GIw81kXFBDfy A/quneG07CfIy6mL9/Vua5MsNdZcO9S848IO7Nxy1FH5qXvmeUKwlNM1+GIKyGrUDxJF 3+Rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=TA91SgG5FWr84Ainw4nzA+9Xtss/d/5HZBJd4c03Uw8=; b=ICi4/0JQPg8Vj52wNf1H886WKVfX9VrhV2W1hKfDAtPJ4A8M7iRe4kpXC6yQsxauvb CW/K3vGQj7QmUNyo3qbC7e8yYCYXkMQlDVHwsBH+JALMaM/eP0bRIW1jybk0xLiEbDvR FCzoUYTNIbOru9EXiy/gbnl45Gf5XVs9/Sh8AwxDn7p+j4rctruSU9YY/pXXZKlE3qyX 4z+uDkG89epnrOr0y2jpuqr3+7hp0/t1JTVzmkyoRjOGAPmsXcYzQ20ECG2na31x5UfO KI5VH15VMzjx7DKvCWnn2cYWbKXA3Jlydyg+2K7u0Av307plqJ/XHzxo5PK+pZIO/EON F7lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=g5p2QmVP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d29-20020a056402401d00b004618cd22f7bsi4911691eda.142.2022.10.28.11.04.51; Fri, 28 Oct 2022 11:05:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=g5p2QmVP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229948AbiJ1R5R (ORCPT + 99 others); Fri, 28 Oct 2022 13:57:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230060AbiJ1R5M (ORCPT ); Fri, 28 Oct 2022 13:57:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DFFC1EA57D; Fri, 28 Oct 2022 10:57:11 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D10E0629A0; Fri, 28 Oct 2022 17:57:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 38A06C433D7; Fri, 28 Oct 2022 17:57:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666979830; bh=C9+YCGC1n24X+HLB2Ag9bB27vqjvZDxZ4l2jLCIpHnM=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=g5p2QmVPjiHfDV6KtfaHaTaEyksRUljwjIsdl9/TCabZ3VwoXaqr86R5N6vEM529m 33eVMtGmwT3U+MzwIVKTYnI7UHYijLsFSYj2Q3seospsZxA4WJ46iBRj+Sa8tuqnTu QPyCPGbrsNDzYprPSwgEF621KxZ4hZRuded3ezWRIxjRenmDCuWVtX+9iJYkj05K3T u53wukn8SIReKPu+UD/Hec9vXyDWVj++yb8g6kX/jFR423bRjk6BzQAt7i1cOODgGw Luc4eqheG936kyU6zZm9l+/w9IiIbmuYmSAriECqm9Yxh/iq5S+yYwCzfsntjaxt4G fA3tSt9xbeW1A== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id DDBB25C0692; Fri, 28 Oct 2022 10:57:09 -0700 (PDT) Date: Fri, 28 Oct 2022 10:57:09 -0700 From: "Paul E. McKenney" To: "Elliott, Robert (Servers)" Cc: Zhen Lei , Frederic Weisbecker , Neeraj Upadhyay , Josh Triplett , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Joel Fernandes , "rcu@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v2 1/3] sched: Add helper kstat_cpu_softirqs_sum() Message-ID: <20221028175709.GP5600@paulmck-ThinkPad-P17-Gen-1> Reply-To: paulmck@kernel.org References: <20221022124525.2080-1-thunder.leizhen@huawei.com> <20221022124525.2080-2-thunder.leizhen@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 27, 2022 at 07:04:53PM +0000, Elliott, Robert (Servers) wrote: > > > Similar to kstat_cpu_irqs_sum(), it counts the sum of all software > > interrupts on a specified CPU. > > > > diff --git a/include/linux/kernel_stat.h b/include/linux/kernel_stat.h > > @@ -67,6 +67,17 @@ static inline unsigned int kstat_softirqs_cpu(unsigned int irq, int cpu) > > return kstat_cpu(cpu).softirqs[irq]; > > } > > > > +static inline unsigned int kstat_cpu_softirqs_sum(int cpu) > > +{ > > + int i; > > + unsigned int sum = 0; > > + > > + for (i = 0; i < NR_SOFTIRQS; i++) > > + sum += kstat_softirqs_cpu(i, cpu); > > + > > + return sum; > > +} > > In the function upon which this is based: > > irqs_sumstruct kernel_stat { > unsigned long irqs_sum; > unsigned int softirqs[NR_SOFTIRQS]; > }; > > static inline unsigned int kstat_cpu_irqs_sum(unsigned int cpu) > { > return kstat_cpu(cpu).irqs_sum; > } > > kstat_cpu_irqs_sum returns an unsigned long as an unsigned int, which > could cause large values to be truncated. Should that return > unsigned long? The only existing caller is fs/proc/stat.c which > puts it into a u64: > u64 sum = 0; > ... > sum += kstat_cpu_irqs_sum(i); > > The softirqs field is an unsigned int, so the new function doesn't have > this inconsistency. Good point! Zhen Lei, thoughts? Thanx, Paul