From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (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 432443590C5 for ; Fri, 5 Dec 2025 18:43:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764960230; cv=none; b=LjF7xYri9rcLFqvwVsa+k5JxDyUXNf/CFxnAqG+dvlNM70UwH9bUKau/idh/bEHu6Qsj4/awU1XWC6GgDanIVywxQeLn+7yrqhCb79MDgInmBSUKZ899tYWdbci3X4rye2dIdlJaiEhiMs3fg6+8sSBYEHjo0IbNwmdDrvr2r/k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764960230; c=relaxed/simple; bh=zXmSTbRqtgSPzfcZ9sIic4ONxv0eRdgyFsyts/yohko=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tky4jT6qk/cJ9kRSmFs0n0TJnOxO+volDtF47nuGMSww9gn3+9a8gO9ihgXQsLb3CSUndEZDKRGq0uPXk/FKxtGlpkUpVo7jbBbZVSHO0uWeNBeSTv9O607mMeLpWmMyaxDUjO0HTu1HkVfDnFO3yQ77YGKlnMeABWbB9b/PSUY= 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=OfhyHe7V; arc=none smtp.client-ip=209.85.128.50 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="OfhyHe7V" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-47775fb6cb4so20244535e9.0 for ; Fri, 05 Dec 2025 10:43:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764960224; x=1765565024; 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=e7/1aFNzttjrEmgH/GMBCatif7QSIzkL0ePxeJlf7xU=; b=OfhyHe7VDo/eaKC0mggmG8BMqPZ2UMPPHfRTcbu+jgLs0orIGQdGpgJHM5OvFBJSb1 YzabOp4v/eyAdRox6LEokmTrbiHaWreYBrm9CPyzJ3iZry3TdOgpkbCCLBGDS8Ftk4mA DFZ34+2fsvPVM37rPkW2SKL92NM+rGvYp6l6MkfPW9hFD4D6d2T6ukxeJawK2Kf9B2NC Vg943IghXGJ8EW4jGKQo/GCknHIslxTCtYCqEHmYCdSmWWQXgP8fH0IvggAKAmAUUQ/V HRou49ueQOoMOqBFcpMRdadc0LEMf8/rt1zDdzKgKsIUspiL3ksjv8mSBMvcC0TN0Y92 YhAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764960224; x=1765565024; 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=e7/1aFNzttjrEmgH/GMBCatif7QSIzkL0ePxeJlf7xU=; b=e4P5BBKx59QqAzXJ2R5ottJE/lB5TSQxn4xpZoqBmrSuVYlzV2dqElh5RWuCQ/99Tp oEA8qWjiQvbtH6XjfgTIoiwI3H6Gz+fv1ZVlPBqEs4MLP5UNzxtReoDJupsG/XWwdcqx APQNzzkfKTg9Li8f9RHii2X16Tl5nGTEhhqDi68LF8RFS+neyb2auKhdk95jfLsrAYy8 9teh1FBezrCCZCMXECt7aOXKNJhNGx1qw6CU9LtFHrM4Y/IMZ6knq1Guc7D+c97vkG9V dCmT3+LG1KcRFlrOHliF5+PW5RKIXwyy6JWTDEdCX2iyYbJvavVdqUv9Jb69uk7J26FI Fdyg== X-Forwarded-Encrypted: i=1; AJvYcCWV/WcQHOcCem2v9504ODws3cPUPRYd+J3iiQvw80buzz6efReKayp6yqCcRQsHGfKam28dldPc3httSOE=@vger.kernel.org X-Gm-Message-State: AOJu0Yw7uZ/c4L9kDDWjB08ipNeFM2dHQSI5hSUHepPkcFMi2J0C3v2g my3+VqXvXXwOv0XOPOUGXFszcG1pv35WNe5NsSiOfC+r8fRtRuzAClqK X-Gm-Gg: ASbGncuu2zBVLmSsHjzm3vEXqCWeYrJwc5TC9WD97JfrHfczf7GYk2BIi7oQ+xPQ5TE WPzrIKJCHmca4qFSLvYFRUC8UJ9fBwC8H95V3uB33HCJJ6pVmxuxO3sJV+GxWmVcXBEb5bEXcBd YHAWtLYRxWXgxasVnLZXXXgbFipFHM3n6QNXHsa0ktU6A0jTdgAHJ2zbZ/mDGnpXyBM/5X8BQwl EedLtDw66NsqrIjWXm0Ct9DWVuFQzXNbJtaMgNPKpQK1J3ggsY7oy8ldP6qWw87TsY0xb7gb+Pb eoN2F8Q3O0A569qSBaOXoRTKahb4pBDWJLDIk6QK2I2kY5tBD8I4RaXRsfLVhijTKokHK3b/+Im SnpcwNQbgGc5hMGJKTBpErIESZz9zWiD/38rsPtvqqMUVusOdOBjo+zHMhTcKoMra0y6G55NviD UmgUiaaEd2WBc1AC29o8lqgd53162am+11Do+bnl+knFW7Xo4C1RgX2wIMMnZDJ1M= X-Google-Smtp-Source: AGHT+IH8oQxJQ9sHJHXNwvtBMYhabUCo0pJF3Bl/B5exsqnwQClYz+RaZdZVl5XMm6m3+ze+0+ysCA== X-Received: by 2002:a05:600c:6097:b0:477:632a:fd67 with SMTP id 5b1f17b1804b1-47939df44c9mr3268515e9.12.1764960223836; Fri, 05 Dec 2025 10:43:43 -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-47930c76edcsm96140615e9.11.2025.12.05.10.43.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Dec 2025 10:43:43 -0800 (PST) Date: Fri, 5 Dec 2025 18:43:42 +0000 From: David Laight To: Lorenzo Stoakes Cc: Andrew Morton , David Hildenbrand , "Liam R . Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , oliver.sang@intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: avoid use of BIT() macro for initialising VMA flags Message-ID: <20251205184342.2cfcc73e@pumpkin> In-Reply-To: <20251205175037.1287366-1-lorenzo.stoakes@oracle.com> References: <20251205175037.1287366-1-lorenzo.stoakes@oracle.com> 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=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 5 Dec 2025 17:50:37 +0000 Lorenzo Stoakes wrote: > Commit 2b6a3f061f11 ("mm: declare VMA flags by bit") significantly changed > how VMA flags are declared, utilising an enum of VMA bit values and > ifdef-fery VM_xxx flag declarations via macro. > > As part of this change, it uses INIT_VM_FLAG() to define VM_xxx flags from > the newly introduced VMA bit numbers. > > However, use of this macro results in apparently unfortunate macro > expansion and resulted in a performance degradation.This appears to be due > to the (__force int), which is required for the sparse typechecking to > work. Does sparse complain if you just add 0? As in: #define INIT_VM_FLAG(name) BIT(VMA_ ## name ## _BIT + 0u) That should change the type without affecting what BIT() expands to. David > > Avoid macro expansion issues by simply using 1UL << bitnum. > > Reported-by: kernel test robot > Closes: https://lore.kernel.org/oe-lkp/202512041634.150c7e4f-lkp@intel.com > Signed-off-by: Lorenzo Stoakes > --- > > Andrew - note I've referenced the linux-next commit number above, could you > replace with the upstream commit hash once your PR is taken? Thanks! > > include/linux/mm.h | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index a2f38fb68840..c4438b30c140 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -395,7 +395,8 @@ enum { > #undef DECLARE_VMA_BIT > #undef DECLARE_VMA_BIT_ALIAS > > -#define INIT_VM_FLAG(name) BIT((__force int) VMA_ ## name ## _BIT) > +#define INIT_VM_FLAG(name) (1UL << (__force int)(VMA_ ## name ## _BIT)) > + > #define VM_READ INIT_VM_FLAG(READ) > #define VM_WRITE INIT_VM_FLAG(WRITE) > #define VM_EXEC INIT_VM_FLAG(EXEC) > -- > 2.52.0 >