Message ID | a18dcae310f74dcb9c6fc01d5bdc0568@AcuMS.aculab.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-80220-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1659145dyb; Sun, 25 Feb 2024 08:58:07 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWzsGBMIl2qZwdJ0hv8sVQv4WPmTFwGFKhZ1tWy/ClWcx0cw9T/4ms1Ify6x9XPtfwr4N5INUYVQpnK099DKtsKnujt6A== X-Google-Smtp-Source: AGHT+IEqXz/gJQoYurO5wTHDyK0PG7kfJy9mP+QVp1hmDp47jB6aZ244v2sonwOkICiXMr2v5L+d X-Received: by 2002:a05:620a:40ca:b0:783:e30b:3759 with SMTP id g10-20020a05620a40ca00b00783e30b3759mr6992867qko.35.1708880286936; Sun, 25 Feb 2024 08:58:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708880286; cv=pass; d=google.com; s=arc-20160816; b=zgCbggsTIZ9tN+9AmG6xWudoK4LEtVaVlMEGVlWlsDkRVKmXJ3HRWXp2c60JnR/o9B gXXdURNJOoiHogGaB5uBE2AUD7k+M+AdjwrR/CYXLc8mpkLoEWD7k2crszkS5sssf4DL T0oIjoszqCONm59mwbuWyI77+FtJJ5C9RqbvIzRD7INVYus6lJugyn7nfo+906fuH5y0 y6JPMuSqfE5XN4wknKd/nBtz0Bd0LnWAMmbe1E9RKtfTikBpTNlwofbHG9KT+gkdIUnB jN0ENAJxVRES62sPuXKGI/vXm4kvpFTY8UpO8DePcEy4o1cjdz8LwQovFzB9jkV3A1j+ mmdQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:accept-language :in-reply-to:references:message-id:date:thread-index:thread-topic :subject:cc:to:from; bh=rsRmR/5ns1TyNV7cG+3v8oWYZhfwk+FvC/YgG4vlK0I=; fh=nGE692sbVdRvha6RYbzMUXtm1nr/30sV7frdtDN2z14=; b=fe0uEvxDMi3WZh28S2NpHMiGZgfd0bMxOGvkqU6wA+5n6Z0PH4A2N/4VCPrnMOohCk bP5XWafM786GJmqNfCkbKFytmN0C5xVF0ctaq6BRzo6q72oHBaXg+DpFQoJcsEHY5XKI upBzxDG03hi2hHP4X3SI/2KibOxWlZjy503sIzBWvqb8V3M1CvU1xLm6hDyb+b7tbOaL lotGhLUlCAcSIRCk3frIsnIPxUhtreMu/BEOisxdlT8l0FUYIgqQVneH9g4TH0BjJeXk oKKZ4QJXwqhn87j30JuoJmgenqZiu/UeHxTusoJzeCaRA5iFh/m0bxezi4JQ8JuD+7sL 71Mg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=aculab.com dmarc=pass fromdomain=aculab.com); spf=pass (google.com: domain of linux-kernel+bounces-80220-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80220-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id t11-20020a05620a450b00b00787cc7e1c7dsi1705590qkp.137.2024.02.25.08.58.06 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 08:58:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80220-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=aculab.com dmarc=pass fromdomain=aculab.com); spf=pass (google.com: domain of linux-kernel+bounces-80220-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80220-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 91A8B1C2040D for <ouuuleilei@gmail.com>; Sun, 25 Feb 2024 16:58:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9D3BA156C2; Sun, 25 Feb 2024 16:57:13 +0000 (UTC) Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0ABE1182D4 for <linux-kernel@vger.kernel.org>; Sun, 25 Feb 2024 16:57:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.58.86.151 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708880232; cv=none; b=KjBekuj2Yl4gVKTGZ6o55r+1pUvxKFbafedZJ6dlrDv7YeSE89OBHpLHvbUD9j7O6UQyjCpkwtMfpresrdku99GOjA38AIYIdl6U0KsSV277+tYjkXHnevCtY/2ywwQzrfhxC4TlFOkKIOG/FN2Zo3x+Il4FUeQuWg4WoZVTemc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708880232; c=relaxed/simple; bh=ldiOEy1AqqZRm2jpxplq9I8qQHwbubdPAOsFwLgRl3Q=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: MIME-Version:Content-Type; b=UZ4KMA78Pkf0Xx4aIBjXSX5UVT3zLrXbA9LLdBBJ+A306e+5+MgilN90aZJW9A0G4l/YIXZ3nu84yHHgoJffJsAULZvNPTjIGenC8IdPKCBvxlS/zXlFXUWHYNyfB0kR5USXpu6Z1E8N7MPIM1Ja6M1hkveTiDiv2WtvviSnV3M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ACULAB.COM; spf=pass smtp.mailfrom=aculab.com; arc=none smtp.client-ip=185.58.86.151 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ACULAB.COM Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=aculab.com 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-209-DBxHGHkZP8yW0XsruhqEOw-1; Sun, 25 Feb 2024 16:57:00 +0000 X-MC-Unique: DBxHGHkZP8yW0XsruhqEOw-1 Received: from AcuMS.Aculab.com (10.202.163.6) by AcuMS.aculab.com (10.202.163.6) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Sun, 25 Feb 2024 16:56:59 +0000 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Sun, 25 Feb 2024 16:56:59 +0000 From: David Laight <David.Laight@ACULAB.COM> To: "'linux-kernel@vger.kernel.org'" <linux-kernel@vger.kernel.org>, "'Linus Torvalds'" <torvalds@linux-foundation.org>, 'Netdev' <netdev@vger.kernel.org>, "'dri-devel@lists.freedesktop.org'" <dri-devel@lists.freedesktop.org> CC: 'Jens Axboe' <axboe@kernel.dk>, "'Matthew Wilcox (Oracle)'" <willy@infradead.org>, 'Christoph Hellwig' <hch@infradead.org>, "'linux-btrfs@vger.kernel.org'" <linux-btrfs@vger.kernel.org>, "'Andrew Morton'" <akpm@linux-foundation.org>, 'Andy Shevchenko' <andriy.shevchenko@linux.intel.com>, "'David S . Miller'" <davem@davemloft.net>, 'Dan Carpenter' <dan.carpenter@linaro.org>, "'Jani Nikula'" <jani.nikula@linux.intel.com> Subject: [PATCH next v2 11/11] minmax: min() and max() don't need to return constant expressions Thread-Topic: [PATCH next v2 11/11] minmax: min() and max() don't need to return constant expressions Thread-Index: AdpoC6KUHy5Z1N7yRkiaBkc7ZdEdRQ== Date: Sun, 25 Feb 2024 16:56:58 +0000 Message-ID: <a18dcae310f74dcb9c6fc01d5bdc0568@AcuMS.aculab.com> References: <0fff52305e584036a777f440b5f474da@AcuMS.aculab.com> In-Reply-To: <0fff52305e584036a777f440b5f474da@AcuMS.aculab.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> 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: quoted-printable X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791890855688637758 X-GMAIL-MSGID: 1791890855688637758 |
Series |
minmax: Optimise to reduce .i line length
|
|
Commit Message
David Laight
Feb. 25, 2024, 4:56 p.m. UTC
After changing the handful of places max() was used to size an on-stack
array to use max_const() it is no longer necessary for min() and max()
to return constant expressions from constant inputs.
Remove the associated logic to reduce the expanded text.
Remove the 'hack' that allowed max(bool, bool).
Fixup the initial block comment to match current reality.
Signed-off-by: David Laight <david.laight@aculab.com>
---
include/linux/minmax.h | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
Changes for v2:
- Typographical and spelling corrections to the commit messages.
Patches unchanged.
Comments
Hi David,
kernel test robot noticed the following build warnings:
[auto build test WARNING on drm-misc/drm-misc-next]
[also build test WARNING on linux/master mkl-can-next/testing kdave/for-next akpm-mm/mm-nonmm-unstable linus/master v6.8-rc6]
[cannot apply to next-20240223 dtor-input/next dtor-input/for-linus axboe-block/for-next horms-ipvs/master next-20240223]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/David-Laight/minmax-Put-all-the-clamp-definitions-together/20240226-005902
base: git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
patch link: https://lore.kernel.org/r/a18dcae310f74dcb9c6fc01d5bdc0568%40AcuMS.aculab.com
patch subject: [PATCH next v2 11/11] minmax: min() and max() don't need to return constant expressions
config: i386-buildonly-randconfig-001-20240226 (https://download.01.org/0day-ci/archive/20240226/202402261720.EAMC0eHM-lkp@intel.com/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240226/202402261720.EAMC0eHM-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202402261720.EAMC0eHM-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> arch/x86/mm/pgtable.c:437:14: warning: variable length array used [-Wvla]
437 | pmd_t *pmds[MAX_PREALLOCATED_PMDS];
| ^~~~~~~~~~~~~~~~~~~~~
arch/x86/mm/pgtable.c:180:31: note: expanded from macro 'MAX_PREALLOCATED_PMDS'
180 | #define MAX_PREALLOCATED_PMDS MAX_UNSHARED_PTRS_PER_PGD
| ^~~~~~~~~~~~~~~~~~~~~~~~~
arch/x86/mm/pgtable.c:113:2: note: expanded from macro 'MAX_UNSHARED_PTRS_PER_PGD'
113 | max_t(size_t, KERNEL_PGD_BOUNDARY, PTRS_PER_PGD)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/minmax.h:152:27: note: expanded from macro 'max_t'
152 | #define max_t(type, x, y) __careful_cmp(max, (type)(x), (type)(y), __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/minmax.h:62:2: note: expanded from macro '__careful_cmp'
59 | #define __careful_cmp(op, x, y, uniq) ({ \
| ~~~~~~~~~~~
60 | _Static_assert(__types_ok(x, y), \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
61 | #op "(" #x ", " #y ") signedness error, fix types or consider u" #op "() before " #op "_t()"); \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
62 | __cmp_once(op, x, y, uniq); })
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/minmax.h:57:2: note: expanded from macro '__cmp_once'
57 | __cmp(op, __x_##uniq, __y_##uniq); })
| ^
include/linux/minmax.h:52:26: note: expanded from macro '__cmp'
52 | #define __cmp(op, x, y) ((x) __cmp_op_##op (y) ? (x) : (y))
| ^
1 warning generated.
vim +437 arch/x86/mm/pgtable.c
1db491f77b6ed0 Fenghua Yu 2015-01-15 432
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 433 pgd_t *pgd_alloc(struct mm_struct *mm)
1ec1fe73dfb711 Ingo Molnar 2008-03-19 434 {
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 435 pgd_t *pgd;
184d47f0fd3651 Kees Cook 2018-10-08 436 pmd_t *u_pmds[MAX_PREALLOCATED_USER_PMDS];
184d47f0fd3651 Kees Cook 2018-10-08 @437 pmd_t *pmds[MAX_PREALLOCATED_PMDS];
1ec1fe73dfb711 Ingo Molnar 2008-03-19 438
1db491f77b6ed0 Fenghua Yu 2015-01-15 439 pgd = _pgd_alloc();
1ec1fe73dfb711 Ingo Molnar 2008-03-19 440
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 441 if (pgd == NULL)
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 442 goto out;
4f76cd382213b2 Jeremy Fitzhardinge 2008-03-17 443
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 444 mm->pgd = pgd;
4f76cd382213b2 Jeremy Fitzhardinge 2008-03-17 445
25226df4b9be7f Gustavo A. R. Silva 2022-09-21 446 if (sizeof(pmds) != 0 &&
25226df4b9be7f Gustavo A. R. Silva 2022-09-21 447 preallocate_pmds(mm, pmds, PREALLOCATED_PMDS) != 0)
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 448 goto out_free_pgd;
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 449
25226df4b9be7f Gustavo A. R. Silva 2022-09-21 450 if (sizeof(u_pmds) != 0 &&
25226df4b9be7f Gustavo A. R. Silva 2022-09-21 451 preallocate_pmds(mm, u_pmds, PREALLOCATED_USER_PMDS) != 0)
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 452 goto out_free_pmds;
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 453
f59dbe9ca6707e Joerg Roedel 2018-07-18 454 if (paravirt_pgd_alloc(mm) != 0)
f59dbe9ca6707e Joerg Roedel 2018-07-18 455 goto out_free_user_pmds;
f59dbe9ca6707e Joerg Roedel 2018-07-18 456
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 457 /*
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 458 * Make sure that pre-populating the pmds is atomic with
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 459 * respect to anything walking the pgd_list, so that they
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 460 * never see a partially populated pgd.
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 461 */
a79e53d85683c6 Andrea Arcangeli 2011-02-16 462 spin_lock(&pgd_lock);
4f76cd382213b2 Jeremy Fitzhardinge 2008-03-17 463
617d34d9e5d832 Jeremy Fitzhardinge 2010-09-21 464 pgd_ctor(mm, pgd);
25226df4b9be7f Gustavo A. R. Silva 2022-09-21 465 if (sizeof(pmds) != 0)
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 466 pgd_prepopulate_pmd(mm, pgd, pmds);
25226df4b9be7f Gustavo A. R. Silva 2022-09-21 467
25226df4b9be7f Gustavo A. R. Silva 2022-09-21 468 if (sizeof(u_pmds) != 0)
f59dbe9ca6707e Joerg Roedel 2018-07-18 469 pgd_prepopulate_user_pmd(mm, pgd, u_pmds);
4f76cd382213b2 Jeremy Fitzhardinge 2008-03-17 470
a79e53d85683c6 Andrea Arcangeli 2011-02-16 471 spin_unlock(&pgd_lock);
4f76cd382213b2 Jeremy Fitzhardinge 2008-03-17 472
4f76cd382213b2 Jeremy Fitzhardinge 2008-03-17 473 return pgd;
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 474
f59dbe9ca6707e Joerg Roedel 2018-07-18 475 out_free_user_pmds:
25226df4b9be7f Gustavo A. R. Silva 2022-09-21 476 if (sizeof(u_pmds) != 0)
f59dbe9ca6707e Joerg Roedel 2018-07-18 477 free_pmds(mm, u_pmds, PREALLOCATED_USER_PMDS);
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 478 out_free_pmds:
25226df4b9be7f Gustavo A. R. Silva 2022-09-21 479 if (sizeof(pmds) != 0)
f59dbe9ca6707e Joerg Roedel 2018-07-18 480 free_pmds(mm, pmds, PREALLOCATED_PMDS);
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 481 out_free_pgd:
1db491f77b6ed0 Fenghua Yu 2015-01-15 482 _pgd_free(pgd);
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 483 out:
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 484 return NULL;
4f76cd382213b2 Jeremy Fitzhardinge 2008-03-17 485 }
4f76cd382213b2 Jeremy Fitzhardinge 2008-03-17 486
From: kernel test robot <lkp@intel.com> > Sent: 26 February 2024 09:42 ... > If you fix the issue in a separate patch/commit (i.e. not just a new version of > the same patch/commit), kindly add following tags > | Reported-by: kernel test robot <lkp@intel.com> > | Closes: https://lore.kernel.org/oe-kbuild-all/202402261720.EAMC0eHM-lkp@intel.com/ > > All warnings (new ones prefixed by >>): > > >> arch/x86/mm/pgtable.c:437:14: warning: variable length array used [-Wvla] > 437 | pmd_t *pmds[MAX_PREALLOCATED_PMDS]; Not surprisingly I missed X86_CONFIG_PAE builds :-) David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
Hi David,
kernel test robot noticed the following build warnings:
[auto build test WARNING on drm-misc/drm-misc-next]
[also build test WARNING on linux/master mkl-can-next/testing kdave/for-next akpm-mm/mm-nonmm-unstable linus/master v6.8-rc6]
[cannot apply to next-20240223 dtor-input/next dtor-input/for-linus axboe-block/for-next horms-ipvs/master next-20240223]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/David-Laight/minmax-Put-all-the-clamp-definitions-together/20240226-005902
base: git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
patch link: https://lore.kernel.org/r/a18dcae310f74dcb9c6fc01d5bdc0568%40AcuMS.aculab.com
patch subject: [PATCH next v2 11/11] minmax: min() and max() don't need to return constant expressions
config: i386-randconfig-011-20240226 (https://download.01.org/0day-ci/archive/20240226/202402261802.9ShoXRwY-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240226/202402261802.9ShoXRwY-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202402261802.9ShoXRwY-lkp@intel.com/
All warnings (new ones prefixed by >>):
arch/x86/mm/pgtable.c: In function 'pgd_alloc':
>> arch/x86/mm/pgtable.c:437:9: warning: ISO C90 forbids variable length array 'pmds' [-Wvla]
437 | pmd_t *pmds[MAX_PREALLOCATED_PMDS];
| ^~~~~
vim +/pmds +437 arch/x86/mm/pgtable.c
1db491f77b6ed0 Fenghua Yu 2015-01-15 432
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 433 pgd_t *pgd_alloc(struct mm_struct *mm)
1ec1fe73dfb711 Ingo Molnar 2008-03-19 434 {
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 435 pgd_t *pgd;
184d47f0fd3651 Kees Cook 2018-10-08 436 pmd_t *u_pmds[MAX_PREALLOCATED_USER_PMDS];
184d47f0fd3651 Kees Cook 2018-10-08 @437 pmd_t *pmds[MAX_PREALLOCATED_PMDS];
1ec1fe73dfb711 Ingo Molnar 2008-03-19 438
1db491f77b6ed0 Fenghua Yu 2015-01-15 439 pgd = _pgd_alloc();
1ec1fe73dfb711 Ingo Molnar 2008-03-19 440
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 441 if (pgd == NULL)
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 442 goto out;
4f76cd382213b2 Jeremy Fitzhardinge 2008-03-17 443
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 444 mm->pgd = pgd;
4f76cd382213b2 Jeremy Fitzhardinge 2008-03-17 445
25226df4b9be7f Gustavo A. R. Silva 2022-09-21 446 if (sizeof(pmds) != 0 &&
25226df4b9be7f Gustavo A. R. Silva 2022-09-21 447 preallocate_pmds(mm, pmds, PREALLOCATED_PMDS) != 0)
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 448 goto out_free_pgd;
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 449
25226df4b9be7f Gustavo A. R. Silva 2022-09-21 450 if (sizeof(u_pmds) != 0 &&
25226df4b9be7f Gustavo A. R. Silva 2022-09-21 451 preallocate_pmds(mm, u_pmds, PREALLOCATED_USER_PMDS) != 0)
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 452 goto out_free_pmds;
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 453
f59dbe9ca6707e Joerg Roedel 2018-07-18 454 if (paravirt_pgd_alloc(mm) != 0)
f59dbe9ca6707e Joerg Roedel 2018-07-18 455 goto out_free_user_pmds;
f59dbe9ca6707e Joerg Roedel 2018-07-18 456
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 457 /*
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 458 * Make sure that pre-populating the pmds is atomic with
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 459 * respect to anything walking the pgd_list, so that they
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 460 * never see a partially populated pgd.
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 461 */
a79e53d85683c6 Andrea Arcangeli 2011-02-16 462 spin_lock(&pgd_lock);
4f76cd382213b2 Jeremy Fitzhardinge 2008-03-17 463
617d34d9e5d832 Jeremy Fitzhardinge 2010-09-21 464 pgd_ctor(mm, pgd);
25226df4b9be7f Gustavo A. R. Silva 2022-09-21 465 if (sizeof(pmds) != 0)
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 466 pgd_prepopulate_pmd(mm, pgd, pmds);
25226df4b9be7f Gustavo A. R. Silva 2022-09-21 467
25226df4b9be7f Gustavo A. R. Silva 2022-09-21 468 if (sizeof(u_pmds) != 0)
f59dbe9ca6707e Joerg Roedel 2018-07-18 469 pgd_prepopulate_user_pmd(mm, pgd, u_pmds);
4f76cd382213b2 Jeremy Fitzhardinge 2008-03-17 470
a79e53d85683c6 Andrea Arcangeli 2011-02-16 471 spin_unlock(&pgd_lock);
4f76cd382213b2 Jeremy Fitzhardinge 2008-03-17 472
4f76cd382213b2 Jeremy Fitzhardinge 2008-03-17 473 return pgd;
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 474
f59dbe9ca6707e Joerg Roedel 2018-07-18 475 out_free_user_pmds:
25226df4b9be7f Gustavo A. R. Silva 2022-09-21 476 if (sizeof(u_pmds) != 0)
f59dbe9ca6707e Joerg Roedel 2018-07-18 477 free_pmds(mm, u_pmds, PREALLOCATED_USER_PMDS);
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 478 out_free_pmds:
25226df4b9be7f Gustavo A. R. Silva 2022-09-21 479 if (sizeof(pmds) != 0)
f59dbe9ca6707e Joerg Roedel 2018-07-18 480 free_pmds(mm, pmds, PREALLOCATED_PMDS);
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 481 out_free_pgd:
1db491f77b6ed0 Fenghua Yu 2015-01-15 482 _pgd_free(pgd);
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 483 out:
d8d5900ef8afc5 Jeremy Fitzhardinge 2008-06-25 484 return NULL;
4f76cd382213b2 Jeremy Fitzhardinge 2008-03-17 485 }
4f76cd382213b2 Jeremy Fitzhardinge 2008-03-17 486
diff --git a/include/linux/minmax.h b/include/linux/minmax.h index c08916588425..5e65c98ff256 100644 --- a/include/linux/minmax.h +++ b/include/linux/minmax.h @@ -8,13 +8,10 @@ #include <linux/types.h> /* - * min()/max()/clamp() macros must accomplish three things: + * min()/max()/clamp() macros must accomplish several things: * * - Avoid multiple evaluations of the arguments (so side-effects like * "x++" happen only once) when non-constant. - * - Retain result as a constant expressions when called with only - * constant expressions (to avoid tripping VLA warnings in stack - * allocation usage). * - Perform signed v unsigned type-checking (to generate compile * errors instead of nasty runtime surprises). * - Unsigned char/short are always promoted to signed int and can be @@ -22,13 +19,19 @@ * - Unsigned arguments can be compared against non-negative signed constants. * - Comparison of a signed argument against an unsigned constant fails * even if the constant is below __INT_MAX__ and could be cast to int. + * + * The return value of min()/max() is not a constant expression for + * constant parameters - so will trigger a VLA warging if used to size + * an on-stack array. + * Instead use min_const() or max_const() which do generate constant + * expressions and are also valid for static initialisers. */ #define __typecheck(x, y) \ (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1))) /* Allow unsigned compares against non-negative signed constants. */ #define __is_ok_unsigned(x) \ - (is_unsigned_type(typeof(x)) || (__is_constexpr(x) ? (x) + 0 >= 0 : 0)) + (is_unsigned_type(typeof(x)) || (__is_constexpr(x) ? (x) >= 0 : 0)) /* Check for signed after promoting unsigned char/short to int */ #define __is_ok_signed(x) is_signed_type(typeof((x) + 0)) @@ -53,12 +56,10 @@ typeof(y) __y_##uniq = (y); \ __cmp(op, __x_##uniq, __y_##uniq); }) -#define __careful_cmp(op, x, y, uniq) \ - __builtin_choose_expr(__is_constexpr((x) - (y)), \ - __cmp(op, x, y), \ - ({ _Static_assert(__types_ok(x, y), \ - #op "(" #x ", " #y ") signedness error, fix types or consider u" #op "() before " #op "_t()"); \ - __cmp_once(op, x, y, uniq); })) +#define __careful_cmp(op, x, y, uniq) ({ \ + _Static_assert(__types_ok(x, y), \ + #op "(" #x ", " #y ") signedness error, fix types or consider u" #op "() before " #op "_t()"); \ + __cmp_once(op, x, y, uniq); }) #define __careful_cmp_const(op, x, y) \ (BUILD_BUG_ON_ZERO(!__is_constexpr((x) - (y))) + \