From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f170.google.com (mail-qt1-f170.google.com [209.85.160.170]) (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 06BB5314D07 for ; Fri, 20 Mar 2026 16:18:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774023531; cv=none; b=BcFl2owRbK+LGTcKTQftyjMZWs5oQl/6qo+q2f5lNMypTKV8YKkm3CKSSmAOZZwWkLhsjmQwLHCwchkCFChPg3cGiYt8mgwiNwCJnJjYMQnoHprtLA5XeFC0/2rhYwUM+ofw96qooauIUeBgoEKXJ4XzTVc4XBUshvNTkJQzQD8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774023531; c=relaxed/simple; bh=Pz6nanbcIMdx9OLtY5ES8cobwXqZW1ve9u1iOLT+Ehk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=U4qWmkRK08mlvTd5rZFkOYW15y4xs6rYlO+JqjEGYqEai5c4eBizrregzngf/F/XlYQ9X1we6oiCFwaKj97D/s5XUP24fYy/DHH8QuhB3R5RLDsIR8tcNW8jo4obo85CVT28KLkK7Ud/8KYGY+aSYoAqXrWzRpVEBhbKenVfVdo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org; spf=pass smtp.mailfrom=cmpxchg.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b=n/36GcV0; arc=none smtp.client-ip=209.85.160.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b="n/36GcV0" Received: by mail-qt1-f170.google.com with SMTP id d75a77b69052e-50904a8f421so6862881cf.2 for ; Fri, 20 Mar 2026 09:18:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg.org; s=google; t=1774023528; x=1774628328; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=NUC9Vc+AJ09E5gPwZ2pPgypATV+QcloFSVvErmSfs2M=; b=n/36GcV0F1BZ41FuNIclGW+wFAKKtw/AJgOgpMq4BvrPyH9+0neqTEijUSHUfnm3FR fq4cyEz3equajxB68gi7r+rLThbmTd7jm1qku+emhCCTxh0gZ60VfKDL1BiO028SI7Im v66ZOrJT5EPPTD72PqnDFt/sZpeHlwZ7acziJNNLCeFIoHdKpamoVxr/Dnl6qhQr1tmi RGIYIufjtmmrKy8nJrOxfwq095BpxmCzKMmeSf5r5DynkOL7fD6S7G3ah3TqkNB3KIW7 71sNCAMU1xgGeCmL90xDv2EOh+KRZ4sjStFPzA5SytEhixgpgFOMpkIJ9JaVmRSyUwJ4 hLLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774023528; x=1774628328; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NUC9Vc+AJ09E5gPwZ2pPgypATV+QcloFSVvErmSfs2M=; b=WyO6wVkpfIVgLmGAM5FK7QscRIUwTabOxfkmPZkZ/uqiavQ29+3c9QQ/fdrH+fUtRl TJ+3dPj9FrqC/Qsc/bDSqb1El7t6NHb4ID4pEX0uRljRygWQBnES7PqUk9rirLyUIhZt YYi5Z8OP9QG+oojowR/x9wkLUOGLw3VQcY0OIAFk7caVYpxqOc0tkJrI8vzicJhDvlYk JNQmghlG+h+4OIEtXIOeaib6CEjIggicpLbriz3XGej3MgI0/4riO1nMLavIZG8ZE5r5 AGlPCyUXsOPNaalZcaet3JFwzi5+jqLrz01Y4R+oHtppDphwBuSXx87LMbrX0ehTh8l5 T32g== X-Forwarded-Encrypted: i=1; AJvYcCUvbLdhN5n5Inq1IEPDh63L9BA/zMIKYnDVKP3RQhP5wjKMAwE6yNRBDy1OeX6QjGMPmC2H4ahA3PZrl3o=@vger.kernel.org X-Gm-Message-State: AOJu0Yx8R6dXNyYtCawcNWt0J5dk71eyup7bp9p6gjdB/ePJAdaYRTai Au9nWCBZI9TIhDoZJ7BllHRtxpxCPteVl+mTQPrWJL/eUntEV/Z6dyUjzWM4wt/bqOE+GQE+dGi KMnd0 X-Gm-Gg: ATEYQzx1h2cJs3IfTHXHFiM4PxcsHXuhYf/CYPsWjigOJ4/y26aPR08DE5uexwB+nae f11v4N8iCqmiFiskvDYWx6c7yjjGSsOpOq8WtiOBAZMdC1FdUXoSyLczOb0zdTcpE6EhRTKTLQp 9zMCJLmkaeWdHK+6s3ZZ8UAMru6k9W1E6/YaAzMchf1ZrBx2dNPWBlZ9D9fBXxAj/jFRtpyOD9p WWMNSj11syBwLI8//wHUdKPTKvTjOOwHcI/vTr162Wc+NzTEHD8KseZBjwLirdFHGw05czme4vT YGdPBgqZ6bCTq5VrvnQJvZhRII3Y8zd3tN3+HnyGw+uRn8dtQHo2jSmCPBg2rpFoToyI14vLqzZ lhmTEKlDIwOODzWsTcRquiotW+XPToGH31m/ouJfJTLWB/OSul//rfkCKf61DPWxumKvcKq2ZLO I+N21FGBehdOx5A03Rz5hRnA== X-Received: by 2002:a05:622a:1b29:b0:50b:2900:6644 with SMTP id d75a77b69052e-50b37552ea3mr55701461cf.51.1774023527784; Fri, 20 Mar 2026 09:18:47 -0700 (PDT) Received: from localhost ([2603:7000:c00:3a00:365a:60ff:fe62:ff29]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-50b36b50fa8sm29731471cf.0.2026.03.20.09.18.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Mar 2026 09:18:47 -0700 (PDT) Date: Fri, 20 Mar 2026 12:18:43 -0400 From: Johannes Weiner To: Shakeel Butt Cc: Andrew Morton , David Hildenbrand , Yosry Ahmed , Zi Yan , "Liam R. Howlett" , Usama Arif , Kiryl Shutsemau , Dave Chinner , Roman Gushchin , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 5/7] mm: list_lru: introduce caller locking for additions and deletions Message-ID: References: <20260318200352.1039011-1-hannes@cmpxchg.org> <20260318200352.1039011-6-hannes@cmpxchg.org> 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-Disposition: inline In-Reply-To: On Wed, Mar 18, 2026 at 01:51:04PM -0700, Shakeel Butt wrote: > On Wed, Mar 18, 2026 at 03:53:23PM -0400, Johannes Weiner wrote: > > Locking is currently internal to the list_lru API. However, a caller > > might want to keep auxiliary state synchronized with the LRU state. > > > > For example, the THP shrinker uses the lock of its custom LRU to keep > > PG_partially_mapped and vmstats consistent. > > > > To allow the THP shrinker to switch to list_lru, provide normal and > > irqsafe locking primitives as well as caller-locked variants of the > > addition and deletion functions. > > > > Reviewed-by: David Hildenbrand (Arm) > > Signed-off-by: Johannes Weiner > > One nit below, other than that: > > Acked-by: Shakeel Butt > > > > > -static inline void lock_list_lru(struct list_lru_one *l, bool irq) > > +static inline void lock_list_lru(struct list_lru_one *l, bool irq, > > + unsigned long *irq_flags) > > { > > - if (irq) > > + if (irq_flags) > > + spin_lock_irqsave(&l->lock, *irq_flags); > > + else if (irq) > > If we move __list_lru_walk_one to use irq_flags then we can remove the irq > param. It is reclaim code path and I don't think additional cost of irqsave > would matter here. The workingset shrinker's isolation function uses unlock_irq() and cond_resched(). That would be non-trivial to rewrite - pass flags around; keep irqs disabled for the whole reclaim cycle; break it into a two-stage process. This sounds like a higher maintenance burden than the bool here. I know there is some cost to this distinction, but I actually do find it useful to know the difference. It's self-documenting context.