From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D250C001DF for ; Tue, 25 Jul 2023 02:00:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230041AbjGYCAr (ORCPT ); Mon, 24 Jul 2023 22:00:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229475AbjGYCAp (ORCPT ); Mon, 24 Jul 2023 22:00:45 -0400 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7108610F0; Mon, 24 Jul 2023 19:00:44 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4R90c76d3gz4f3nb1; Tue, 25 Jul 2023 10:00:39 +0800 (CST) Received: from [10.174.178.55] (unknown [10.174.178.55]) by APP4 (Coremail) with SMTP id gCh0CgAHcLPGLL9k+mv8Og--.60794S3; Tue, 25 Jul 2023 10:00:40 +0800 (CST) Subject: Re: [PATCH 1/2] softirq: fix integer overflow in function show_stat() To: Matthew Wilcox 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 References: <20230724132224.916-1-thunder.leizhen@huaweicloud.com> <20230724132224.916-2-thunder.leizhen@huaweicloud.com> From: "Leizhen (ThunderTown)" Message-ID: <6e38e31f-4413-1aff-8973-5c3d660bedea@huaweicloud.com> Date: Tue, 25 Jul 2023 10:00:38 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CM-TRANSID: gCh0CgAHcLPGLL9k+mv8Og--.60794S3 X-Coremail-Antispam: 1UD129KBjvJXoWrKFyrJFWDKrWkZr13KF1xXwb_yoW8JF17pF yUKw1UGr4kCFyxAr92qr18GF4xAws8Ja45Zr17Ca4IvFZ8Ar9IgF47GrWjqasrWr9agw4F van2gr9rCayYv3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvIb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6r1F6r1fM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4 vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7Cj xVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x 0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG 6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFV Cjc4AY6r1j6r4UM4x0Y48IcVAKI48JM4IIrI8v6xkF7I0E8cxan2IY04v7Mxk0xIA0c2IE e2xFo4CEbIxvr21l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxV Aqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q 6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6x kF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWrZr1j6s0DMIIF0xvEx4A2jsIE 14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf 9x07UWE__UUUUU= X-CM-SenderInfo: hwkx0vthuozvpl2kv046kxt4xhlfz01xgou0bp/ X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On 2023/7/24 21:50, Matthew Wilcox wrote: > 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). Yes, I think patch 2/2 can be dropped. I reduced the number of soft interrupts generated in one second, and actually 100+ or 1000 is normal. But I think patch 1/2 is necessary. The sum of the output scattered values does not match the output sum. To solve this problem, we only need to adjust the type of a local variable. > > . > -- Regards, Zhen Lei