Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp3181201rwo; Mon, 24 Jul 2023 07:25:31 -0700 (PDT) X-Google-Smtp-Source: APBJJlEJJBY+PdlREQvrLnehlPPOMFHXHBUsemN0nXyx0DOEBFTZrHw8lYQy4XZmphgnIWA9VLsE X-Received: by 2002:ac2:58d7:0:b0:4fb:89e2:fc27 with SMTP id u23-20020ac258d7000000b004fb89e2fc27mr4529853lfo.54.1690208731322; Mon, 24 Jul 2023 07:25:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690208731; cv=none; d=google.com; s=arc-20160816; b=VGwkCjJlBVuKSYV8HBZJ24HfcGLj43G41vqJKTwpntYyry121C+T37IQgI0BFq+VY3 FujNWn+CKPfFGCy2Ks+KvEAtaPoE4Soq9lvohniWqnKxhDlUpxcueS50XwCn5k+k5Z3G S6//WSybvzxLUdxeVCGXyeTgk2X9BeNbknG+InbHRfRhERGiMTOgXeJAhsUWv06RzK6W FBdrBh8HUaPKsI9EewM6yJ0IEyCPVBulnok9LyE6I8YOLDHHUFSo2PqSbdNdZNVosQCP 6efWwHhHICW7hSmlvyLcD4Bdw+GopkTE+XOs6Dg6y0hKeJNTy4gzlgsuiHGikGm6eE+R 5Kmg== 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:message-id:subject:cc:to:from:date:dkim-signature; bh=kSn9lV4vudoTTwyV0i7jCpPn7hBfXbWHV74eMs9f/8g=; fh=LKOOaNZ8W4Aq5OjHSBtKNEnFSUa+w/1e6d6T8aHfgSE=; b=EnD7AzupjU0JWiGOfn2dAQJzhiGZ9bwtYfkASBP9cNScI/cFD37aPf47BbqKF13MYA 9DgNZJST2/09hcjKtseNawsjFQxRAbfswt/DVq+5gyBVeB3wwTZW9DvXjzzgPcc9nDqZ F0LGpki/SscdnYIjYp26qtpaxSMF7mRVVu/+aPb0wZbb1U0m6gT6/76aqpxoN/aLh1Yg ky5IS8zVItG70PYjxGzmpP1llrHv9QR1x5/RE/nj0A9UovnsQ6PRriTKOSAcSHrf2Avf DBqYPDaqxFhz6uueYW8a/ra9sECo1QwCx7eea9JanhHA+St2oUKBRIx5VCm+NFoRZ7iB l6nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=j4kIojTC; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j20-20020a50ed14000000b0051a4a3c37e7si6484192eds.492.2023.07.24.07.25.06; Mon, 24 Jul 2023 07:25:31 -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=@infradead.org header.s=casper.20170209 header.b=j4kIojTC; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229477AbjGXNyX (ORCPT + 99 others); Mon, 24 Jul 2023 09:54:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231145AbjGXNyB (ORCPT ); Mon, 24 Jul 2023 09:54:01 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82773268F; Mon, 24 Jul 2023 06:51:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=kSn9lV4vudoTTwyV0i7jCpPn7hBfXbWHV74eMs9f/8g=; b=j4kIojTCOg98Fw6ZFrGzkYPujC kCMHHdYaeasub7NeINN3HYoTGMhECncDowHv89ci2pgAVGZyOQt3++6JqmJIuv8sRW0VCQQO1RsHA 6x+RtwoP9TwHaNrtpMdi9k9XBVc7RQK2FKmptWdh/ZAhIyyfyEQZac1ny04d9ljai6Gql2vv9WX8z 9w2hB5qCGYx1nvS475F0BJeQsCHKHKAMk735kj2zj7B57Z46j+IMbH55S2as0bCYYaSfmmlExCwuP FAy8PY5+G/M2ZhBvCUJeXgBcU9GGXHo3UtLZnWGtEhPsJ1rrLwXLaO4q4+iGahV+DkbqHbyfFvr5V 8qgx02Xw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qNvxi-004SZV-Ja; Mon, 24 Jul 2023 13:50:58 +0000 Date: Mon, 24 Jul 2023 14:50:58 +0100 From: Matthew Wilcox To: thunder.leizhen@huaweicloud.com Cc: "Paul E . McKenney" , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , rcu@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Zhen Lei Subject: Re: [PATCH 1/2] softirq: fix integer overflow in function show_stat() Message-ID: References: <20230724132224.916-1-thunder.leizhen@huaweicloud.com> <20230724132224.916-2-thunder.leizhen@huaweicloud.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230724132224.916-2-thunder.leizhen@huaweicloud.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE 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 Mon, Jul 24, 2023 at 09:22:23PM +0800, thunder.leizhen@huaweicloud.com wrote: > From: Zhen Lei > > The statistics function of softirq is supported by commit aa0ce5bbc2db > ("softirq: introduce statistics for softirq") in 2009. At that time, > 64-bit processors should not have many cores and would not face > significant count overflow problems. Now it's common for a processor to > have hundreds of cores. Assume that there are 100 cores and 10 > TIMER_SOFTIRQ are generated per second, then the 32-bit sum will be > overflowed after 50 days. 50 days is long enough to take a snapshot. You should always be using difference between, not absolute values, and understand that they can wrap. We only tend to change the size of a counter when it can wrap sufficiently quickly that we might miss a wrap (eg tens of seconds).