From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) (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 6FCE041C0CF for ; Mon, 2 Mar 2026 17:12:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772471576; cv=none; b=k9bBtdWJEqRC0kk3Rl7EK8zQL0E/Z5VeGW4AbYn0MnEJyBC9WRCAlK46tNjtHX5aBshpeoV/vsXxg7DjbnacB/hR+8/igZ5Vqt+LukbMrP3eTmJNEn5TuCcGLKFpq8AjtqtB0ir3MbMI+rXUveRoWfrdB8Ngp65ozkdZQIgdfEY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772471576; c=relaxed/simple; bh=OPMdAESDGIeNBXWvxHugves4Hzd4QErL9F1dxR1ce2s=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=sOOM2J/ZHWKrodzONLObh1mC5WsyX5SMa8GCMGoTiM29jdHuiz7ZZqQxQILV0xAtztbPIC4BKDEUM9zUX3spCnDC6syGogKNPNxaMUa8FykMunWSSAZ8K0zTX1Zfhuvd7gcaUR6fGAG3Jb0pnRxMFRB8ngIO20L9UNB6YrXs43M= 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=HXSjX6Y3; arc=none smtp.client-ip=209.85.222.178 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="HXSjX6Y3" Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-8cb3825b0fbso451496185a.0 for ; Mon, 02 Mar 2026 09:12:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg.org; s=google; t=1772471573; x=1773076373; 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=5NYeVLOSy11BGz8w/+PkZCxVtenIhIQDcWYxLFf6PHw=; b=HXSjX6Y3Kbbyhg8PFC6PULNuHgRypkdFcwX13pHNQHk7IlXcJsj+Dcqgo6wVzxHxGd LMa1Z5vOGrDHaaNRuuoeS5K6N7S7bUowUwFORTdwbe9ZOyI+Gf40vMLhwzvYLhk0w5Hj Yeay/sHvJbjPRkcM9htfAodZzc5qH++sH6FwX4ONN4ME3WL3TlP84+MvcF67p33QeZHn JJGmou/0co8WQwZotIKvqOTplVYwA/V56j7dAju13K7AqVoavnNFRwXda3ArK88k6sW9 awpDVK1f1cpwGAk6k9eeh9CK7QV2z+SghimOH/n83sLLpUSVUwzeYNi97XfjzKV51wv0 eETg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772471573; x=1773076373; 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=5NYeVLOSy11BGz8w/+PkZCxVtenIhIQDcWYxLFf6PHw=; b=dOlnqKxDuGGjUGTIni19OomZ4dCEa1NTeQoSYvxI3bvEasYiGFxT7JV5E/qQYHRfbE 0ZxTaIJLJqSNXEUsWLg9YDNm5H/RF2bxy6ek2dvljO7oOjZqdReZMI0TMQjGZVCVC6by a8F9GLhGRnCz5iuRI/Oxz+NoIHzB9skN7Ciwjk3md4pjEkOqotMTwUCMVPS17ZOhgASW ItvGUWV/9hY7fWB7RIchBuU85z5CQyiti28fc1LrxYSyYRhgEAJmgN7F3nUtDLFQfCYN MwkRXrQgxlXqpcpkyYDkMjiFdoB+/RO3rT8rP+3eWM5IAWPnXNQNYCwfPD6FMsLUHMi4 e7RA== X-Forwarded-Encrypted: i=1; AJvYcCVMW1WHBVEBaB9HIbK7uZ5wx6tiICzrUOw1BeX9NuF+8PTgZXDMHZMHOGixRXJv3kx5lcJE9HTWZTELJEQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxgMmamUfXbDX2O1MPkQcvONkMASZYJzt31IQWTXQYtMevUwT+u Wuj2bG6ghy75axlq45d5OfwyAs6kjJZxsq5g/UXwCEtfAsEmEpKHEOc3u3lL5otIuXE= X-Gm-Gg: ATEYQzyDEt53D04DdQApKipQoP1/j0RucLLREnlxzVC/mru7eQNT+8kWlsXQ7taohjZ v6avHChEzI6M6CaGY/MwK+UBd78yRv3nLpDqwKBSiiPIuomtni3wIIq+dJxkuMQlRK1bnEe/ZKL lqCIUAsCBYqanvBob2cvwHr5rnN3PH3qxkvXwWPBjHkjY4oAoGxdPtrdk/TCRaKigb8Nn5IMrHQ UyChRCjCnl5YMqAgmvaoAMCDJEZpIUGkiBKr780ZUdO4rJu1iX0UhB7sbFHT+rVmvJj9h7Ygkm/ dfzCkEXfB5Oje+/Xjm4n5S2hGmw6g5sCaVGyg9vkUilbworVffty5wrnNAb18MoPY7CZuO/Ksp6 UL0WKYrDUN0k4t4FSxSNwHetk7gbY9ZanZfNxVdg9weVseEOUzTMf1L8IqHhuoeeAM08q8QwYkB imV/bCk3YIo386iyAqTrw+If6GH2ES5Mjx X-Received: by 2002:a05:620a:7012:b0:8c6:af5b:d50a with SMTP id af79cd13be357-8cbc8de839fmr1760779885a.43.1772471573065; Mon, 02 Mar 2026 09:12:53 -0800 (PST) Received: from localhost ([2603:7000:c00:3a00:365a:60ff:fe62:ff29]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-899c7374dd7sm112302256d6.32.2026.03.02.09.12.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Mar 2026 09:12:52 -0800 (PST) Date: Mon, 2 Mar 2026 12:12:48 -0500 From: Johannes Weiner To: Vlastimil Babka Cc: Andrew Morton , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Zi Yan , Mel Gorman , Matthew Wilcox , "David Hildenbrand (Arm)" , Sebastian Andrzej Siewior , Clark Williams , Steven Rostedt , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev Subject: Re: [PATCH 1/3] mm/page_alloc: effectively disable pcp with CONFIG_SMP=n Message-ID: References: <20260227-b4-pcp-locking-cleanup-v1-0-f7e22e603447@kernel.org> <20260227-b4-pcp-locking-cleanup-v1-1-f7e22e603447@kernel.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: <20260227-b4-pcp-locking-cleanup-v1-1-f7e22e603447@kernel.org> On Fri, Feb 27, 2026 at 06:07:58PM +0100, Vlastimil Babka wrote: > The page allocator has been using a locking scheme for its percpu page > caches (pcp) based on spin_trylock() with no _irqsave() part. The trick > is that if we interrupt the locked section, we fail the trylock and just > fallback to the slowpath taking the zone lock. That's more expensive, > but rare, so we don't need to pay the irqsave/restore cost all the time > in the fastpaths. > > It's similar to but not exactly local_trylock_t (which is also newer anyway) > because in some cases we do lock the pcp of a non-local cpu to drain it, in > a way that's cheaper than using IPI or queue_work_on(). > > The complication of this scheme has been UP non-debug spinlock > implementation which assumes spin_trylock() can't fail on UP and has no > state to track whether it's locked. It just doesn't anticipate this > usage scenario. So to work around that we disable IRQs only on UP, > complicating the implementation. Also recently we found years old bug in > where we didn't disable IRQs in related paths - see 038a102535eb > ("mm/page_alloc: prevent pcp corruption with SMP=n"). > > We can avoid this UP complication by realizing that we do not need the > pcp caching for scalability on UP in the first place. Removing it > completely with #ifdefs is not worth the trouble either. Just make > pcp_spin_trylock() return NULL unconditionally on CONFIG_SMP=n. This > makes the slowpaths unconditional, and we can remove the IRQ > save/restore handling in pcp_spin_trylock()/unlock() completely. > > Suggested-by: David Hildenbrand (Arm) > Signed-off-by: Vlastimil Babka (SUSE) Acked-by: Johannes Weiner