Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3824698rwd; Sat, 10 Jun 2023 16:06:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5/Xh3Elw1CeocAexeJhx+IGzcJ0Ztgp/Vk2UERoYcUQTjr4EAaW7k4nTji/8WesNuri3cr X-Received: by 2002:a17:906:4796:b0:973:fd02:a41f with SMTP id cw22-20020a170906479600b00973fd02a41fmr6831275ejc.40.1686438413699; Sat, 10 Jun 2023 16:06:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686438413; cv=none; d=google.com; s=arc-20160816; b=XCNShLW/EaGo6zXq+xAQFHd0c9Vvf2AVKy1O3EDA86ZoAjX9ktsEwwvl9cv+9y1Ph6 0zE6j/ZTXCwX/TcSVaBDswsUnEyMdbOTVbS+8vES/Hw4NdRUy7NjKKNcAGU49/1zRFv4 GKZmvhL836km+eo3MoJssxhRGFns4yTTqq8QMQPSYNVioguFHVB5XCkdCZ10Y2yJpJKM nVfD8ZPXgfkJHSHdPliU4ScRRF6t1uS+PSjRjQcjLouSevOy2OZhTw3QezXiXlg2bjLt lf0Q1chZcI13rDbf4/ZZum3YSoWvMl1zXNzl4UoUvWxVgVTkifZGSuSKpZj1nv81rUb1 HJlQ== 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=VhRcAyBydO+svtLxtZFIn9vCAqGP3Cl7s2InUp/ryqM=; b=k6YmkRZ8nWbIibIZfj7E60f4C1zEfZBaSpCaqoqQLpfvsOv/wUNDvU2SLXWnQ+qGhx I9QD9GTT4MvdDuXY450kN2XW1pt+FA/iT+GplnjeojtWwekJ+/2C8WIQBY1iuewwr+wK v/ffcUM6HrpRtdA5ak/DvrHvO5YI0sm/6t/Uy5b2QywRiGyl2cuKztcvNLhwW/4QEtIv eRVT4/EgrPfaU5MHEogDzBRUIV0ieSu8c6OWqphwvFRj8A/xCQRnLxUCkYDKnrDgmmt4 gqExIigi3bXRY8h4VnXoosLRhCTDqwvx94DcTP7b6Pi2PLnqm28AFOdCwmAgIBh9iN/I U+aw== 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 i14-20020a1709063c4e00b009788ec72d2fsi3585555ejg.620.2023.06.10.16.06.19; Sat, 10 Jun 2023 16:06:53 -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 S232374AbjFJW3c convert rfc822-to-8bit (ORCPT + 99 others); Sat, 10 Jun 2023 18:29:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229622AbjFJW3b (ORCPT ); Sat, 10 Jun 2023 18:29:31 -0400 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BCDD3584 for ; Sat, 10 Jun 2023 15:29:29 -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-202-XgiTLAFcNSyLSvWHXgvipg-1; Sat, 10 Jun 2023 23:29:27 +0100 X-MC-Unique: XgiTLAFcNSyLSvWHXgvipg-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; Sat, 10 Jun 2023 23:29:22 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Sat, 10 Jun 2023 23:29:21 +0100 From: David Laight To: 'Andrew Morton' , Lorenzo Stoakes CC: Lu Hongfei , Uladzislau Rezki , Christoph Hellwig , "open list:VMALLOC" , open list , "opensource.kernel@vivo.com" Subject: RE: [PATCH] mm/vmalloc: Replace the ternary conditional operator with min() Thread-Topic: [PATCH] mm/vmalloc: Replace the ternary conditional operator with min() Thread-Index: AQHZm+gKsZ2mMErDwEmVNd3QmnYBSK+Emzhg Date: Sat, 10 Jun 2023 22:29:21 +0000 Message-ID: <84a2c079fcd44b8490eaf039cd20d2bf@AcuMS.aculab.com> References: <20230609061309.42453-1-luhongfei@vivo.com> <832d7c69-ffd5-4764-8ffe-3a02bef0efb0@lucifer.local> <3fc87d60-4e81-4f49-95f0-0503ad5cdf35@lucifer.local> <20230610150809.babdc5a7919258f066c8637e@linux-foundation.org> In-Reply-To: <20230610150809.babdc5a7919258f066c8637e@linux-foundation.org> 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, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, 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 From: Andrew Morton > Sent: 10 June 2023 23:08 > > On Sat, 10 Jun 2023 22:06:35 +0100 Lorenzo Stoakes wrote: > > > > > OK, as per the pedantic test bot, you'll need to change this to:- > > > > > > > > num = min_t(size_t, remains, PAGE_SIZE); > > PAGE_SIZE is a nuisance. It _usually_ creates the need for a > cast: > > hp2:/usr/src/linux-6.4-rc4> grep -r "min(.*PAGE_SIZE" . | wc -l > 117 > hp2:/usr/src/linux-6.4-rc4> grep -r "min_t(.*PAGE_SIZE" . | wc -l > 279 > > Perhaps it should always have been size_t. > > I suppose we could do > > #define PAGE_SIZE_T (size_t)PAGE_SIZE > > And use that where needed. Mainly because I like the name ;) Or someone take my patches to relax the checks min() does a bit. I think I last posted them in January. Basically: - unsigned v unsigned is always ok. - signed v signed is always ok. - unsigned v signed is ok provided one value is in [0..INT_MAX]. this can be allowed for compile-time constants. The usual 'error case' is unsigned v signed when the values are known (by the person writing the code) to be non-negative. Doing '(x) + 0u + 0ul + 0ull' zero extends the value without ever masking it or 'accidentally' converting a pointer. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)