From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2998AC71159 for ; Thu, 19 Jun 2025 04:37:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AA2F88D0003; Thu, 19 Jun 2025 00:37:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A7B578D0001; Thu, 19 Jun 2025 00:37:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 991588D0003; Thu, 19 Jun 2025 00:37:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 874308D0001 for ; Thu, 19 Jun 2025 00:37:26 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 30772141AAC for ; Thu, 19 Jun 2025 04:37:26 +0000 (UTC) X-FDA: 83570891292.20.FE7910A Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) by imf26.hostedemail.com (Postfix) with ESMTP id 7EFDA140006 for ; Thu, 19 Jun 2025 04:37:23 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=KDDdNLP7; spf=pass (imf26.hostedemail.com: domain of hezhongkun.hzk@bytedance.com designates 209.85.208.174 as permitted sender) smtp.mailfrom=hezhongkun.hzk@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1750307844; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=bQIxwaFwlmZUeVwGDLanhQhj9z8HCaoir3lX4GTDpfc=; b=vKcUPpdD6h3AqAeSroYHN8saV03WPqEN8f7/hjA7PRBef2IUHRcL5RO229hF1HO3SyVKMk I1R3bzlNMQQU0xAUnPEDB8S/BdYXam7x63m1p7LPW+mb/mjw3vdUZw9QW0v9jr7x6Xdayb u3diAHitJBXTjm1YR+RiQclpw+dKp2U= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1750307844; a=rsa-sha256; cv=none; b=BYJrH7n2v73C+m1Lo/WSwci6pQaeY4ozoTAJldYGGVc7cwfXGm0IathSRLje1/1d4c1BsQ aUprjjR1t8uy5f4FFxXj21tamWI/NcP1AJZJk/EtK1ab8nCNGHx2n9rK6SVVqXABv3/v4/ lA3xTtmaMMqI9M9OOVHyU+Tfpw9HpWc= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=KDDdNLP7; spf=pass (imf26.hostedemail.com: domain of hezhongkun.hzk@bytedance.com designates 209.85.208.174 as permitted sender) smtp.mailfrom=hezhongkun.hzk@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-30f30200b51so4164091fa.3 for ; Wed, 18 Jun 2025 21:37:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1750307841; x=1750912641; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=bQIxwaFwlmZUeVwGDLanhQhj9z8HCaoir3lX4GTDpfc=; b=KDDdNLP7TkqZwGm1mCyz3hkDElllQHs03mR1v8gXINlA1C8tt07hFBuOwyUsEHoYER PhLv3lJMkRTAqLD7pssHC58kq6Y6+3vdDCRZrWyC8Lyji6gn59R7fCZ3KH+XDeKvB40n azbF4O4n3U8bqqxc3CSuf7oaTOXADyFwZV7vP1jP3JGfulnU4qBBVenyx+hckHkBD5jk kQjNBXkhoU/X4M9+FlLrf7vLFXXbJ4LdVjhKHPv9hM21dr6D4dwsqTYgHs9dBsjndjfm M1gXd/kykiQLu+GHdjq2/j4SXP2cOuaDK5G8xaA4p/wZYcj/tbjuCLOif535IreZdj55 cDhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750307841; x=1750912641; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bQIxwaFwlmZUeVwGDLanhQhj9z8HCaoir3lX4GTDpfc=; b=HP0VVbm+jB0jyF5YeE77RjI5mJTkpsvnLqBuyLiHBuuseu1lF5vukOf+En8VXtf4i3 iYStKTnfZd2UFiwifOpfTGvqwrb8HSXLVXhvrHIhT54WKvWmaN4vm2J2ZFzc9nOH7rn6 8MYEk2ugECRRllY2kGsHXsFrRBRie3mi4mzvVrlViPk6XiSFNONdWQAmi0JkWnoGEqak kSaWHjezqzb25MDLxifOS5ExvB0J2ZrOFeUI5Ix5Ebc5p6iJxf19sPnb/tdx9q43Akv4 5t29mOzMLISGrb1Yutwo9gcEW62dVcUu9o8TxJccGv4cxOtXuS1nrDemgwfP1/6djMI/ xqCA== X-Forwarded-Encrypted: i=1; AJvYcCUtlohhIT1zBLTvWPRmg5et9DmnGtV4a42ta0oztopIv+kz4iyA3mUOeiN6auwUntYKHohcPatxww==@kvack.org X-Gm-Message-State: AOJu0YzKCmWjRaxDX5ikpA+hYOl8yAaKZPEmPaiVfkTmiNv4iRIJV5eF CHMiw9Azop8+dHKsVP2lPXykplc/mIYWB6P0sA75lca5Gfx+OMHJwm7f2CRx21BqW59yJShPTRy x5XFMv0gD8RsVtJE331Iz6l4S9q3CMj3RoketNLc4Rg== X-Gm-Gg: ASbGncsfcXhRcZSkKymux57oua3LXofjxd464cHooN9rYYdMXCaWl/QYtU81Eircga6 YIoUTbngUmI6cI7hUJ2Zd9Wyp+zU8bjN7xEsyOuz+RAxBAMkfce62Pz1SPIBopLhHf4SD/VX+4O +OqCZFzLrDo50Q1HTDjnle4ML0GTuICIVU4GJ1gcNmtZcyX1fKviCCGko5bA== X-Google-Smtp-Source: AGHT+IF5dQ8UFI8ymtvUN4g32DBa6Wt8mh5aBTjercUAPoQh32HF5tvDZfp++BPTZpKTkQRV27gDFPSDlQMmde52G/M= X-Received: by 2002:a05:651c:60d:b0:32a:7e4c:e915 with SMTP id 38308e7fff4ca-32b4a5d9b14mr46629491fa.29.1750307841263; Wed, 18 Jun 2025 21:37:21 -0700 (PDT) MIME-Version: 1.0 References: <20250618070328.2192849-1-hezhongkun.hzk@bytedance.com> <20250618164334.54616cb2d70a1ee3c1f28a81@linux-foundation.org> In-Reply-To: From: Zhongkun He Date: Thu, 19 Jun 2025 12:36:44 +0800 X-Gm-Features: Ac12FXxuA0Xkm_Lr_Wh9-xqOTQiONZI2ypIGNKehmeDz7Kt5NuFVKShq5Tc9AW0 Message-ID: Subject: Re: [External] Re: [PATCH] mm: rename the oldflags and parameter in memalloc_flags_*() To: Kent Overstreet Cc: Andrew Morton , mhocko@suse.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam03 X-Stat-Signature: ks7c9woiq7r1h9ut3kk76ihrj5xxheo1 X-Rspam-User: X-Rspamd-Queue-Id: 7EFDA140006 X-HE-Tag: 1750307843-38222 X-HE-Meta: U2FsdGVkX185PJDLFpbsTat/DvsVggBSDbB4WmFG3pIuySxSeGDZWsUbJCnDND8DfWJYSKiunilrg+1j8MlHFTVKPt9pp+hIdKvQpTt6IurugxVrc6DzG+sE39AmPNcrZKAVN9F9J2ZYh4Hjy5uzW2wYz7Ffw6e92msbb7MTCHYoOITMtioV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DjTVrztVldw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu, Jun 19, 2025 at 12:17=E2=80=AFPM Kent Overstreet wrote: > > On Thu, Jun 19, 2025 at 11:17:58AM +0800, Zhongkun He wrote: > > On Thu, Jun 19, 2025 at 8:07=E2=80=AFAM Kent Overstreet > > wrote: > > > > > > On Wed, Jun 18, 2025 at 04:43:34PM -0700, Andrew Morton wrote: > > > > On Wed, 18 Jun 2025 15:03:28 +0800 Zhongkun He wrote: > > > > > > > > > The variable name oldflags can indeed be misleading, because > > > > > it does not store the complete original value of flags. > > > > > Instead, it records which flags from the given set are not > > > > > currently set. So rename it. > > > > > > > > > > > > > Your email client is mangling the patches in strange ways. Please = send > > > > yourself a patch, figure out why it didn't apply? > > > > > > > > > --- a/include/linux/sched/mm.h > > > > > +++ b/include/linux/sched/mm.h > > > > > @@ -322,21 +322,21 @@ static inline void might_alloc(gfp_t gfp_ma= sk) > > > > > } > > > > > > > > > > /** > > > > > - * memalloc_flags_save - Add a PF_* flag to current->flags, save= old value > > > > > + * memalloc_flags_save - Add a PF_* flag to current->flags, retu= rn saved flags mask > > > > > * > > > > > * This allows PF_* flags to be conveniently added, irrespective= of current > > > > > * value, and then the old version restored with memalloc_flags_= restore(). > > > > > */ > > > > > -static inline unsigned memalloc_flags_save(unsigned flags) > > > > > +static inline unsigned int memalloc_flags_save(unsigned int flag= s_mask) > > > > > { > > > > > - unsigned oldflags =3D ~current->flags & flags; > > > > > - current->flags |=3D flags; > > > > > - return oldflags; > > > > > + unsigned int saved_flags_mask =3D ~current->flags & flags_mas= k; > > > > > + > > > > > + current->flags |=3D flags_mask; > > > > > + return saved_flags_mask; > > > > > } > > > > > > > > > > -static inline void memalloc_flags_restore(unsigned flags) > > > > > +static inline void memalloc_flags_restore(unsigned int flags_mas= k) > > > > > { > > > > > - current->flags &=3D ~flags; > > > > > + current->flags &=3D ~flags_mask; > > > > > } > > > > > > > > I guess so. Maybe. A bit. Kent, what do you think? > > > > > > Eesh, seems like pointless verbosity to me. Maybe don't change it if = it > > > doesn't need to be changed? > > > > Hi Kent, thanks for your feedback. > > How about this version, only change the 'old' to 'saved'. > > The function does not return the old current->flags value. Instead, > > it returns the subset of flags that were not previously set in current-= >flags, > > so they can later be cleared by memalloc_flags_restore(). The name save= dflags > > makes this behavior clearer and avoids confusion. > > Why change it at all? The returned flags parameter is opaque state that > should only be used by memalloc_flags_restore(), it's not something the > caller should be looking at. > Hi Kent You're right that the returned flags are opaque and only meant for memalloc_flags_restore(), not for inspection by the caller. My motivation for renaming was that the term oldflags might suggest it contains the original current->flags value, which could be misleading when reading the code. Since it actually represents a subset of flags to be cleared later, savedflags seems clearer. That said, if the current naming is considered fine given its opaque nature, I'm happy to drop the rename. Thanks, Zhongkun. > > > > /** > > - * memalloc_flags_save - Add a PF_* flag to current->flags, save old v= alue > > + * memalloc_flags_save - Add a PF_* flag to current->flags, return sav= ed flags > > * > > * This allows PF_* flags to be conveniently added, irrespective of cu= rrent > > * value, and then the old version restored with memalloc_flags_restor= e(). > > */ > > static inline unsigned memalloc_flags_save(unsigned flags) > > { > > - unsigned oldflags =3D ~current->flags & flags; > > + unsigned savedflags =3D ~current->flags & flags; > > current->flags |=3D flags; > > - return oldflags; > > + return savedflags; > > } > > > > Thanks, > > Zhongkun