From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A8824328263 for ; Wed, 21 Jan 2026 19:24:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769023498; cv=none; b=qOtoY2JF1LmV9wwAp+gZf70H7ykvVQMlDm2UbgxWoBy2eumrh1aIv/drYh5f3Kox4iRemXCVnR+v70VgVJPA/fXfVYq2P6pSecO7Ys2ni9Kbdk6M4A/T4NAv1r33jLzmrMHwgkd54hn8c3jLbGgnEpAz46Ew09GkwjTbZKNepxg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769023498; c=relaxed/simple; bh=gyTU4a01nJSUemuXWfV/RQRcTm0unLyKNTrTMAgVgaQ=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eoMqIkAG3entLaCMItocdN0YE9yyDmecf/j6E+RRsz7wrA2qHTroSZfzib3jB5c2j56MjPoMO7ZloNvO+zuSwtBK/QOvyRBHDU0mbtai7zdDB8aY1nBwy+iaxmZl8TPra/UeJ3CUp+Sw5m39W5T4KuDnktsXi6Qt7go5brLdi48= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=B1CPZ4En; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="B1CPZ4En" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-47ff94b46afso1250005e9.1 for ; Wed, 21 Jan 2026 11:24:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769023494; x=1769628294; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=ElU5zBr9MQauCQ2KbtYpyRUNDArLPNpb0ZVER5AU1+w=; b=B1CPZ4EnvybEFLJNowH1tAojRrtgU0Jbxn+EMypYnRN4LK1H0DY07eGFrfKNyWxB2b HAdryWAscMTo0Gtit2zs2vK+fBoYaR+aF+HAR3HhxGNFuQivMKadfBCR3MGd3kXdCism vUwyjtaV7H8GyviqQoUb0O/dfrCm9IRW4n5KYbzpR2seMXe6VjT+FAJ8clgWxVol0Cnm YoMLxRDS+F1Ih8LGlpiLjoHyQTLkSTej4xJOmH1ZeDdD29YhLLikpMnpPlKgRGGs0Y6N h4LZg/ALGfmusFHdpaulQWVdJwRV33NkSTCRILBowDHS1qe5VxqQSmWK3NFI5wVrr7kx FQ8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769023494; x=1769628294; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ElU5zBr9MQauCQ2KbtYpyRUNDArLPNpb0ZVER5AU1+w=; b=EP9+0zUO3vIXwHPZ8GAb9/Hw7I09pvlJcybxWu50XJeKzGbd6icc7wS16N5nM3DqJd rKwuhGCs5LNBuCiTkQlCQYk/A9sBOxNvdfFbnoNc0jkVEkrMzcEwkcpU0VLbqXpu41ty ZYu07Ul7lTLIR7FEWVIQuUI+NEgcWt/ynyP3MgMuyPztd2muBOKZDZplfPjs9xJHNhpY jeCsKHY2XRvPQ9mWqxCcBew4IMMhJ5UT7mZh3O5FbwUAyuQGcirs40AQOmmWhq9SJvsY RgQohPWeBTabVCsUYiieLMOKybAUPIcXm7s0hIuejiiaQ61f/Q7VjS/iZSl+qyngv3EE P07g== X-Forwarded-Encrypted: i=1; AJvYcCWbE4GURuqrtrsGIdIgJbu5i798G43KtKR2yYvfsZxhODoN66MFKBIZSbK06NujtC68C3KJEnS3nNH//Mk=@vger.kernel.org X-Gm-Message-State: AOJu0YyBDGT7DrszpfBDIII8nGpwt009VEySuedEjagCgAyupWc78ctY sUa12/+hsV1bjFX4E3MmYMfuZtYk0hJz7jy2bkpNycElY9D2lCaR8nHaDnrCfg== X-Gm-Gg: AZuq6aJIXtoxM/+Y4tnNhxjkqyOimmKisfqSx3a4CkEkDNO/LVRCZPw1dhDJyrPm/Nr zMVFDm4Cj5At/HmGddlgdsvK7QOmv4dZPQkxmBhwnV6JlstVgFhQ3ZmqRZVDxOGLX5lzxRwcixr 6gjANkQkBD+LeapJ9AQFi4n7xuxghumrAOkQT3OEQFqUWdfZK7XtQ0x2Zpw/0vm0A3BVQvOrw0f fVXFULeBLaY8EF3/UMgRqhG/7AbZC3b1FjwQdN7hf0jJcbf5UPgS6vf034S+ah02KajjTpe/rZZ KEwRY3t9eE2HW0YgPxA4trY77usEyh8mvAX0ex0XNwmVw6KX7yWEK1YAhG8fB0NHELl6e6GJo8I H6JqwxDS/EjyBgxxXX/E/4AW25fxYcysBBav10GOdz8nHpIe3yOtj21vm0LlSv/S1L3h1M8Hoxh HsIzbuoYWXn1/iCyW+449Ee41JMrl5BjXymoBNMuEwu9ik82+5dBxk X-Received: by 2002:a05:600c:1f8f:b0:479:1348:c63e with SMTP id 5b1f17b1804b1-480470829c1mr9500585e9.9.1769023493704; Wed, 21 Jan 2026 11:24:53 -0800 (PST) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4804245320dsm10228595e9.0.2026.01.21.11.24.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jan 2026 11:24:53 -0800 (PST) Date: Wed, 21 Jan 2026 19:24:51 +0000 From: David Laight To: Thomas =?UTF-8?B?V2Vpw59zY2h1aA==?= Cc: Nathan Chancellor , Greg Kroah-Hartman , Thomas Gleixner , Peter Zijlstra , Ingo Molnar , Mathieu Desnoyers , Arnd Bergmann , linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Yury Norov , Lucas De Marchi , Jani Nikula , Vincent Mailhol , Andy Shevchenko , Kees Cook , Andrew Morton Subject: Re: [PATCH next 12/14] bits: move the defitions of BIT() and BIT_ULL() back to linux/bits.h Message-ID: <20260121192451.415f1920@pumpkin> In-Reply-To: <20260121160912-cafca67d-bfc0-414a-adaa-80c863acd93a@linutronix.de> References: <20260121145731.3623-1-david.laight.linux@gmail.com> <20260121145731.3623-13-david.laight.linux@gmail.com> <20260121160912-cafca67d-bfc0-414a-adaa-80c863acd93a@linutronix.de> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Wed, 21 Jan 2026 16:17:18 +0100 Thomas Wei=C3=9Fschuh wrote: > On Wed, Jan 21, 2026 at 02:57:29PM +0000, david.laight.linux@gmail.com wr= ote: > > From: David Laight > >=20 > > The definition of BIT() was moved from linux/bits.h to vdso/bits.h to > > isolate the vdso from 'normal' kernel headers. > > BIT_ULL() was then moved to be defined in the same place for consistenc= y. > >=20 > > Since then linux/bits.h had gained BIT_Unn() and it really makes sense > > for BIT() and BIT_ULL() to be defined in the same place. > >=20 > > Move BIT_ULL() and make code that include both headers use the definiti= on > > of BIT() from linux/bits.h > > Add BIT_U128() for completness. > >=20 > > This lets BIT() pick up the extra compile time checks for W=3D[1c] buil= ds > > that detect errors like: > > long foo(void) { int x =3D 64; return BIT(x); } > > For which clang (silently) just generates a 'return' instruction. > >=20 > > Note that nothing the the x86-64 build relies on the definition in > > vdso/bits.h, linux/bits.h is always included. > >=20 > > Signed-off-by: David Laight > > --- > > include/linux/bits.h | 7 ++++++- > > include/vdso/bits.h | 2 +- > > 2 files changed, 7 insertions(+), 2 deletions(-) > >=20 > > diff --git a/include/linux/bits.h b/include/linux/bits.h > > index 0f559038981d..3dd32b9eef35 100644 > > --- a/include/linux/bits.h > > +++ b/include/linux/bits.h > > @@ -2,7 +2,6 @@ > > #ifndef __LINUX_BITS_H > > #define __LINUX_BITS_H > > =20 > > -#include > > #include > > =20 > > #define BIT_MASK(nr) (UL(1) << ((nr) % BITS_PER_LONG)) > > @@ -89,10 +88,16 @@ int BIT_INPUT_CHECK_FAIL(void) __compiletime_error(= "Bit number out of range"); > > ((unsigned int)BIT_INPUT_CHECK(+(nr), BITS_PER_TYPE(type)) + ((type)1= << (nr))) > > #endif /* defined(__ASSEMBLY__) */ > > =20 > > +/* Prefer this definition of BIT() to the one in vdso/bits.h */ > > +#undef BIT > > +#define __VDSO_BITS_H =20 >=20 > This is ugly. It works :-) I could have put an #ifndef BIT in vdso/bits.h instead. > Why can't the vDSO code make use of those checks, too? > Or use _BITUL() from the UAPI in the vDSO and remove vdso/bits.h. I didn't actually find anything that just needed vdso/bits.h linux/bits.h would get included - eg (IIRC) because of warn_on_once(). I'm not that sure why it got separated, it isn't as though it defines anything that is code version specific. David >=20 > > +#define BIT(nr) BIT_TYPE(unsigned long, nr) > > +#define BIT_ULL(nr) BIT_TYPE(unsigned long long, nr) > > #define BIT_U8(nr) BIT_TYPE(u8, nr) > > #define BIT_U16(nr) BIT_TYPE(u16, nr) > > #define BIT_U32(nr) BIT_TYPE(u32, nr) > > #define BIT_U64(nr) BIT_TYPE(u64, nr) > > +#define BIT_U128(nr) BIT_TYPE(u128, nr) > > =20 > > #if defined(__ASSEMBLY__) > > =20 > > diff --git a/include/vdso/bits.h b/include/vdso/bits.h > > index 388b212088ea..a6ac1e6b637c 100644 > > --- a/include/vdso/bits.h > > +++ b/include/vdso/bits.h > > @@ -4,7 +4,7 @@ =20 > > > #include =20 > > =20 > > +/* Most code picks up BIT() from linux/bits.h */ > > #define BIT(nr) (UL(1) << (nr)) > > -#define BIT_ULL(nr) (ULL(1) << (nr)) > > =20 > > #endif /* __VDSO_BITS_H */ > > --=20 > > 2.39.5 > > =20