From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (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 04BFC2F6188 for ; Sun, 8 Mar 2026 18:00:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772992842; cv=none; b=WXMtXTU+GhWELKut2JnMTJPGVUWJck2hN0or2g3a3z3SKU8uX9Kc6tRkju63ECKUZzM/0tNVt49Vp9DTrwHY9gRS5uU+wlg2CULZ02YRrWgj5HfJ2QWQNqB5PKWl07eFx+ZmWbnW3zQoOJAMwASROCBqfTCUryxB9XnMVs9/GIo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772992842; c=relaxed/simple; bh=9F2s872ZHL+CcQtI8a+ygEFvqMFIMJs7eaUqA/NvTJw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type:Content-Disposition; b=Dh548m9RhUeg+5Ao1MgzgXI0P7CZGmUzb/M7Hf134riBBBbzQJws/lVtTb1Ki39E4gEm4y3yvf1UeJKqwWpCudD8lr2fjOzCt2HCIn4yzPv0711ekkRGmReGbD/NF9ZJNp7Dh1aq5GmtDzQ11YZ7BX9/s19m0Vu5I1HH14/5/1E= 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=HSZlsbw1; arc=none smtp.client-ip=209.85.128.52 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="HSZlsbw1" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-483a233819aso108063075e9.3 for ; Sun, 08 Mar 2026 11:00:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772992839; x=1773597639; darn=vger.kernel.org; h=content-transfer-encoding:content-disposition:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=WigD4xTv35FpDIaB0ncQLYNkLlhATinqtn7c2ncFLjE=; b=HSZlsbw1m/En2jDka6trKpTQ8OrBxaKHtnoYkkZz6OcJ8hem0o4JNTPaoNf5SZpRoT 37YARAqWFW9WT4sKE2fzTzrnD80trf+Njs/y5SKtddqFn9ws0UMRIngbOjjuCTQ/OqEJ oYEdkjHb3EB+rwEDs6U5l8n5Tr51pk2AM06ZcMYXuED4bWV/Squm43reaXv4fNnkLAuI hIQZE5Yzix6WEDQQJiBHoerHsmj0supD8DZI+7XtvhBPDK3fFkfrqfP33Yag+4Fu9Ovc JSgSe1ESVWB6OpbAUkY9yjiapo04NfVjbdt3ewk2gBHIoxDTdiSfNJQyEgeij5wJ7WE3 y86A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772992839; x=1773597639; h=content-transfer-encoding:content-disposition:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WigD4xTv35FpDIaB0ncQLYNkLlhATinqtn7c2ncFLjE=; b=d2hDcjKdrQFH7ZwJ/rcJP6cGrvi0QLrShZ4Ep7yFnmCaqUFpjPoZmY3ucFXMRaCe4N KpiKLiuXHzi4upYv3xW3L0K/8QWwSx0EdyCVz3z+jvtizKN0mIruWOlDSvWbAnGYVn8D iVT5IJ6wm0Mdiz5nw09AFW8LeLOzTj5DX1TqGPsTZhfKC4y1iJMZgoLZqt/gAURz7AmM 7tHfPd5e2Gh0GmGxTmjY2l6ZASBrmA28dV/21i2LcEgjAO3BopIE/+ZG8RMqDJSfoi2e STYdoVU4ObL0t6gtu1v+W5HbKRIcnyQwqNKDmJ7Idvt+zKvmEaY4Yq0Pu7QYkUtZSttN jsIA== X-Forwarded-Encrypted: i=1; AJvYcCXiWtUyr7bwb03t4MDnm8o98VYFo5JjWV9TtIByFqhky83Us9xhK4b2eZxUpOoYRDmk2Scku6A020+SiV4=@vger.kernel.org X-Gm-Message-State: AOJu0YxcpQsU0Ap3ukkyH/BTaSL8RfE9G7VdrzfKRzMrkXE6MAeFMRgO TltLjRbUfXbbqBjaZ9+UZuHeyl3EVCHlD9TFI8Ie5/tNUq4IysblZGzA X-Gm-Gg: ATEYQzyw1Fe2wm4TL5Sd4c/QH7QkQCEjQcVBC/Pe/Jx6atgWIGgWrqwNMRvIyr5y83o OWOMJmxT/KlpmaC72fWZJOKOPInZZcvIXiR+qrV3btsmRZAwsQzVsyZocffksn1Em68JPPYOgU/ oel8s8zc35GzkJhI0eWnQFU42J4ezTLHT6pEip6WyLESDugC0DMO8nEf+egpmspqucBYAZYhLGT MbqR10Clw1WISIm5VRVAZSNxzELEuRi04rfhIVOFTSOk5j1wPLvTfGt4mqagHM8A2REHGKRbD/N 1I1V+aFKJ3rGvoh+CVEFFjJo2PLFgmE7dZ2xDPrnlRsyCdUiNXyOrLvoZo/EEJkK8JDJZwuG7KA RNNb0xUNxzt4gmhCjsr8m12Hv08COOnRhFsy6D50z0lTzf6cFB72ia+fE2kYER2CVBaF3AVYJqU Gd8KPlEgLaBJ5ucDwxnIVrItBsinw8E4p1XO8= X-Received: by 2002:a05:600c:450c:b0:485:358b:e802 with SMTP id 5b1f17b1804b1-485358beaebmr46396005e9.0.1772992838937; Sun, 08 Mar 2026 11:00:38 -0700 (PDT) Received: from WindFlash.powerhub ([2a0a:ef40:1b2a:fa01:9944:6a8c:dc37:eba5]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4853438017bsm119290095e9.0.2026.03.08.11.00.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Mar 2026 11:00:38 -0700 (PDT) From: Leonardo Bras To: Marcelo Tosatti Cc: Leonardo Bras , "Vlastimil Babka (SUSE)" , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Thomas Gleixner , Waiman Long , Boqun Feun , Frederic Weisbecker Subject: Re: [PATCH v2 2/5] Introducing qpw_lock() and per-cpu queue & flush work Date: Sun, 8 Mar 2026 15:00:26 -0300 Message-ID: X-Mailer: git-send-email 2.53.0 In-Reply-To: References: <20260302154945.143996316@redhat.com> <20260302155105.214878062@redhat.com> <682380ba-c8f3-4023-928c-2152e934f8db@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 Content-Transfer-Encoding: 8bit On Tue, Mar 03, 2026 at 01:02:13PM -0300, Marcelo Tosatti wrote: > On Tue, Mar 03, 2026 at 01:03:36PM +0100, Vlastimil Babka (SUSE) wrote: > > On 3/2/26 16:49, Marcelo Tosatti wrote: > > > +#define local_qpw_lock(lock) \ > > > + do { \ > > > + if (static_branch_maybe(CONFIG_QPW_DEFAULT, &qpw_sl)) { \ > > > + migrate_disable(); \ > > > > Have you considered using migrate_disable() on PREEMPT_RT and > > preempt_disable() on !PREEMPT_RT since it's cheaper? It's what the pcp > > locking in mm/page_alloc.c does, for that reason. It should reduce the > > overhead with qpw=1 on !PREEMPT_RT. > > migrate_disable: > Patched kernel, CONFIG_QPW=y, qpw=1: 192 cycles > > preempt_disable: > [ 65.497223] kmalloc_bench: Avg cycles per kmalloc: 184 cycles > > I tried it before, but it was crashing for some reason which i didnt > look into (perhaps PREEMPT_RT was enabled). > > Will change this for the next iteration, thanks. > Hi all, That made me remember that rt spinlock already uses migrate_disable and non-rt spinlocks already have preempt_disable() Maybe it's actually worth adding a local_spin_lock() in spinlock{,_rt}.c whichy would get the per-cpu variable inside the preempt/migrate_disable area, and making use of it in qpw code. That way we avoid nesting migtrate_disable or preempt_disable, and further reducing impact. The alternative is to not have migrate/preempt disable here and actually trust the ones inside the locking primitives. Is there a chance of contention, but I don't remember being able to detect it. Thanks! Leo