Received: by 2002:a05:7412:f584:b0:e2:908c:2ebd with SMTP id eh4csp1968756rdb; Tue, 5 Sep 2023 10:08:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG3YMhxLnp4UfL2irigTUoyDYRMx5t/WInQIa9cKXG0Xzqq6ydOIrAHv4v1ZnVIVPOIZ0pR X-Received: by 2002:a17:90a:4f05:b0:26d:4695:4040 with SMTP id p5-20020a17090a4f0500b0026d46954040mr12490240pjh.4.1693933709932; Tue, 05 Sep 2023 10:08:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693933709; cv=none; d=google.com; s=arc-20160816; b=vBOKWbV+Q5C5zsaQeXVExnwHwNku6o8zyUmS/2q+L9LDVfhpV1u1OdlEfsldOQ4uIs wf1MiOYpMYaLXvKvXkFKLv1EyKnjRrXdLgueMZlwhL4lF28+xaIz3rY2JDR48yyjBWhP ieA5/vNULdLzYqTgrsQYANGeksVkPyy9/ZcCHZDsWW7S834lsQ2ZA7ks2AJlRyBilQ0J vwmy1ZT9sFZeGjSPxTNubmJOjwIOCZQtv2Mned778KSPIuuyypH2AXHB62m8DHgjJcex fRRMmcbmuxEapDb7+GWHwQZKxqlY7XtwXX3KvowJYgaHOxT9nlR2vqOGSGUubKA+94wI +YoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=+dvZfj5r59w5NEUn+sWwdm5757dAchIsbVQaUtNI2ew=; fh=fzFH62d1L8Qy1ZigVQ/Z25XwX1ajeJ9le0nnBGIyLAg=; b=0P5zcoIrKLkw1KNsvEvXZgDZBd4WnGbJXa/6grtEB0VyLXvQx+p7CtyPJFg5QFONbB 0RXCSw9j2tEJcS8kuWFxkDrgLqrO0/YMNGplsnhtHtFnx3e+MS3OrsJQE6sjsQy7sPF9 iRndRf7d1eWTysY4vsHDvP5WgVLc+YKrkYrvWCn3gNxOLMLiyDNSkSTn08+mDn+MbXbt Nj344slSxiLVRtKlxRMMowdELyw7No7IphPRvcKtJVugCGrfxffpQJjD1rZrIn+afLMO lz+m4oB2fJn/36jb5QQtl6xLjDggyCcNzl80PCVwxz29x424GC+BatG1MHLPzhcm/k0U zwdA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t9-20020a17090a950900b00263d0beafafsi11650538pjo.181.2023.09.05.10.08.14; Tue, 05 Sep 2023 10:08:29 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243984AbjIEQtj convert rfc822-to-8bit (ORCPT + 99 others); Tue, 5 Sep 2023 12:49:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354774AbjIEOPg (ORCPT ); Tue, 5 Sep 2023 10:15:36 -0400 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82D9A1A7 for ; Tue, 5 Sep 2023 07:15:32 -0700 (PDT) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with both STARTTLS and AUTH (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-213-W_uhwjSCPzKzgPTx1pZAYg-1; Tue, 05 Sep 2023 15:15:29 +0100 X-MC-Unique: W_uhwjSCPzKzgPTx1pZAYg-1 Received: from AcuMS.Aculab.com (10.202.163.4) by AcuMS.aculab.com (10.202.163.4) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Tue, 5 Sep 2023 15:15:25 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Tue, 5 Sep 2023 15:15:25 +0100 From: David Laight To: "'paulmck@kernel.org'" , Mathieu Desnoyers CC: Denis Arefev , Lai Jiangshan , Josh Triplett , Steven Rostedt , "rcu@vger.kernel.org" , "lvc-project@linuxtesting.org" , "linux-kernel@vger.kernel.org" , "trufanov@swemel.ru" , "vfh@swemel.ru" Subject: RE: [PATCH v2] The value may overflow Thread-Topic: [PATCH v2] The value may overflow Thread-Index: AQHZ3xnFNLjoHgiM306HccvtrgnILrAL+RdggABM0NiAAADkEA== Date: Tue, 5 Sep 2023 14:15:25 +0000 Message-ID: References: <20230904094251.64022-1-arefev@swemel.ru> <429249323d5f41ebbfa4f9e0294b2ddb@AcuMS.aculab.com> <89dc5f3f-f959-0586-6f3c-1481c5d3efc4@efficios.com> <228160e9-96f1-6d1c-06c7-a5336dc93536@efficios.com> In-Reply-To: Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, 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 ... > That would instead be more than 512-16=496 CPUs, correct? 496 CPUs would > only require a 31-bit shift, which should be OK, but 497 would require > a 32-bit shift, which would result in sign extension. If it turns out > that sign extension is OK, then we should get in trouble at 513 CPUs, > which would result in a 33-bit shift (and is that even defined in C?). Not quite right :-) (1 << 31) is int and negative, that gets sign extended before being converted to 'unsigned long' - so has the top 33 bits set. (1 << 32) is undefined, the current x86 cpu ignore the high shift bits so it is (1 << 0). If the mask is being used to optimise a search the code might just happen to work! David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)