From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 9D5FE34A799 for ; Sun, 12 Jul 2026 21:43:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783892639; cv=none; b=MZzMjRySl8TsGY3k4XYZQzRfVicXhXreKDVrjQHuy8VPQhomCOPGqh82aR+zlj2Np4jgCDc0jmHXSFSXFDxcVAD6qaDi5qyTpjKLCN+jK3QYWoFBT1C9JgZEPkwJdCfhvvEnZ9SER0uG8CdbOPshkuWv49qOGhwTdZsrYmk+BSA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783892639; c=relaxed/simple; bh=Ncd+Nr6ElASUJrESkoYzFZAFZojPrdkqIeZ6KwQJ7lk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type:Content-Disposition; b=jehfgz+ENl2Ovw2+mFPXSgvg4SofABuhKyc/KhU9tyuHuxXvImHyQyTaaWgbvvaffyvyhx3rzcemIrQQ2DQ17Q+nNBEMibNytMm4hBM9M5nvkskSxCF2BPzwg4sNknR/uZPTAd5Bb7v9UqRk9ju7VXZsjdE5PRnDz2rDcMPhstA= 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=AZKNgL7x; arc=none smtp.client-ip=209.85.128.49 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="AZKNgL7x" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-493bb510ce4so17324965e9.1 for ; Sun, 12 Jul 2026 14:43:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783892636; x=1784497436; darn=vger.kernel.org; h=content-transfer-encoding:content-disposition:content-type :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=HCxD8V4rPJmnTk5Z484eCKRQlIsY0VOuU0QQtm5539w=; b=AZKNgL7xdrMlACtmZRTDtNywfaRyvyVbj8MW1gKds2+83tZ9EVEruUbe8w+EsVfwlG gXMN5Of4yiU1DHQH+tLdysAh62SQaPGM9/xplVFwwCVhMY9Xa84fUzQtZVEMzay0G08C uvWKjVWheQepbqeyF6FTQhfC6wTuNMr45mvjal92m7Vu3r3uHxe9ucOjUT/EEf4cHWf1 wkhvyCuc82UiSXWLLSsVT++ZvrMPAhW29hFs7VBfw6bI8cHo2R2/5akeUoAFijRNPmo/ 3wq3+jplO7vwLUiHQDVjEsq38sUhC5FvBsKyqGhXuI23Fm6V4OeFHd4d9hRTWD9zBsXH myxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783892636; x=1784497436; h=content-transfer-encoding:content-disposition:content-type :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:content-type; bh=HCxD8V4rPJmnTk5Z484eCKRQlIsY0VOuU0QQtm5539w=; b=hrSoAdQ5DXYqZ9hMAiJ7b6+Og98iyHG8xykC5+hB42Xa1vJSn39tN3YoA11uPVsXod oiZHslBAYp5Rg0t0hN2RNxWH7B3Yw3bvPNfoZkANj8x3nTipMePXqvinfSvNfOzaBUHj C4SN70ElvljBJ5UFOKxuB4Wf0wtAqxkIiymmfLki1Kz95IvtegNWnkhe1PKCgn454kWC 8tkX16tlvabJxWPHDR/8j6k4T3JJnYg2BHyC5N29XYJmTmfZ7WRJEWm9nzK3/SRiEQ6k clmLgOEIGA1ELBBkWZTQeFQMJpnPJdjPSjHvz4me+lQCb06Rn9JIv6Hhp93REdnjumJl /8yg== X-Forwarded-Encrypted: i=1; AHgh+RomNQvfJjE9g3NFpIXMsdCFeSnXxPFIUVJh/IH5JEcX4VtpIJQD7QTFBc7W0e9815vDX/ZZ4fYtlTxUk/s=@vger.kernel.org X-Gm-Message-State: AOJu0Yy9IZAndJ+4wdUx1TBSuhPQmFNa3XeTvAQW7jijvD6zGIsSDHzi 24xxvLuueirintH9ba0UsI9kxbGMvhKPVVf0j5nWBKh4w4czAJAI+fje X-Gm-Gg: AfdE7cnLVD8kshIfx1dWBtQp3Qha0XoioRiS6oYjwvAIEQnITJ7ctB2P15/UhQ1aYZ7 zHOYgobrU/ePipfzIUvHUP/MpZ5At6OtCnoal0HYQ+zpi/tN5X+TijPkwfcT9fyPzMcZz9UoQEI g52rTKgt0+HJl4PBGdEBLp4ENPz+JvHcdcUEE7gkl75zJjocLtkwnVG/QwhanZs+n3fnGpHR6dZ XvlAvmBofJF409ImoWOHBakaRy4HbEvKQSB73XdQimvZtYUZIeH4Q8QSGw96waeOYlGu0ZxOi7G +TWDjRthrHok/ESYbfin2jUzhObKMISro9zXma5N95vR8oVO2zAslYv/r8O1M67gXOq5ieYj9Uj hSLOftPHsS16SL7HFh0Pa5PN2PGWtmPvhmIa9PNfitgDBF/hAatq5ZOK7Gp3vifhBy2KAAPl8fe CbTul05jfEx9GhRSSuIw4a5w== X-Received: by 2002:a05:600c:4691:b0:493:f764:1f69 with SMTP id 5b1f17b1804b1-493f87d5d44mr61691195e9.8.1783892635821; Sun, 12 Jul 2026 14:43:55 -0700 (PDT) Received: from WindFlash.powerhub ([2a0a:ef40:f61:3b01:d08a:833b:756:8fce]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493ffd304d8sm42196365e9.0.2026.07.12.14.43.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jul 2026 14:43:55 -0700 (PDT) From: Leonardo Bras To: Sebastian Andrzej Siewior Cc: Leonardo Bras , Jonathan Corbet , Shuah Khan , Peter Zijlstra , Ingo Molnar , Will Deacon , Boqun Feng , Waiman Long , Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Jann Horn , Pedro Falcato , Brendan Jackman , Johannes Weiner , Zi Yan , Harry Yoo , Hao Li , Christoph Lameter , David Rientjes , Roman Gushchin , Chris Li , Kairui Song , Kemeng Shi , Nhat Pham , Baoquan He , Barry Song , Youngjun Park , Qi Zheng , Shakeel Butt , Axel Rasmussen , Yuanchu Xie , Wei Xu , "Borislav Petkov (AMD)" , Randy Dunlap , Feng Tang , Dapeng Mi , Kees Cook , Marco Elver , Jakub Kicinski , Li RongQing , Eric Biggers , "Paul E. McKenney" , Nathan Chancellor , Nicolas Schier , Miguel Ojeda , Thomas =?iso-8859-1?Q?Wei=DFschuh?= , Thomas Gleixner , Douglas Anderson , Gary Guo , Christian Brauner , Pasha Tatashin , Coiby Xu , Masahiro Yamada , Frederic Weisbecker , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-rt-devel@lists.linux.dev, Marcelo Tosatti Subject: Re: [PATCH v4 3/4] swap: apply new pw_queue_on() interface Date: Sun, 12 Jul 2026 18:43:48 -0300 Message-ID: X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260520150736.HZnlFkv7@linutronix.de> References: <20260519012754.240804-1-leobras.c@gmail.com> <20260519012754.240804-4-leobras.c@gmail.com> <20260520150736.HZnlFkv7@linutronix.de> 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 Wed, May 20, 2026 at 05:07:36PM +0200, Sebastian Andrzej Siewior wrote: > On 2026-05-18 22:27:49 [-0300], Leonardo Bras wrote: > > after digesting the slub patch, > > > @@ -882,38 +879,38 @@ static inline void __lru_add_drain_all(bool force_all_cpus) > > * If the paired barrier is done at any later step, e.g. after the > > * loop, CPU #x will just exit at (C) and miss flushing out all of its > > * added pages. > > */ > > WRITE_ONCE(lru_drain_gen, lru_drain_gen + 1); > > smp_mb(); > > > > cpumask_clear(&has_mm_work); > > cpumask_clear(&has_bh_work); > > for_each_online_cpu(cpu) { > > - struct work_struct *mm_work = &per_cpu(lru_add_drain_work, cpu); > > + struct pw_struct *mm_pw = &per_cpu(lru_add_drain_pw, cpu); > > struct work_struct *bh_work = &per_cpu(bh_add_drain_work, cpu); > > > > if (cpu_needs_mm_drain(cpu)) { > > - INIT_WORK(mm_work, lru_add_drain_per_cpu); > > - queue_work_on(cpu, mm_percpu_wq, mm_work); > > + INIT_PW(mm_pw, lru_add_drain_per_cpu, cpu); > > + pw_queue_on(cpu, mm_percpu_wq, mm_pw); > > __cpumask_set_cpu(cpu, &has_mm_work); > > } > > > > if (cpu_needs_bh_drain(cpu)) { > > INIT_WORK(bh_work, bh_add_drain_per_cpu); > > queue_work_on(cpu, mm_percpu_wq, bh_work); > > __cpumask_set_cpu(cpu, &has_bh_work); > > } > > } > > > > for_each_cpu(cpu, &has_mm_work) > > - flush_work(&per_cpu(lru_add_drain_work, cpu)); > > + pw_flush(&per_cpu(lru_add_drain_pw, cpu)); > > > > for_each_cpu(cpu, &has_bh_work) > > flush_work(&per_cpu(bh_add_drain_work, cpu)); > > Why do we have two iterations here? Is it just a proof of concept that > is not complete yet? I am curious why it is okay/needed to "remove" the > one workqueue but not the other. Maybe the other does not bother as much > as the other does. Argh, sorry about the above :/ Slub was converted on a previous patchset version, and rebasing worked fine. I should have properly checked if any other mechanism was added in the file, but ended up just checking the one that was already converted. > > But essentially we can't use a spin_lock_t here because due to the > hotpath nature of the code it will kill performance. Correct > So instead we do it > anyway but behind a switch so that only those suffer from this that do > not want to suffer from workqueue interruption on a NOHZ full system, > right? Yes, one can choose to pay the price to use spinlocks here and have less workqueue interruptions, if !CONFIG_PREEMPT_RT In case of CONFIG_PREEMPT_RT, we have the local_lock() already becoming a rt_spinlock(), so it already pays the price to hold the lock. So it should be basically free on this scenario, and save time by doing the operation remotelly instead of scheduling it. > > I thought that this improved since commit > ff042f4a9b050 ("mm: lru_cache_disable: replace work queue synchronization with synchronize_rcu") > > Did it get worse or was it not entirely gone? > I worked in this patchset majorly after that commit date, and it was still an issue up to last time Marcelo tested. Not sure of the impact of above commit, but I suppose it may have brought some improvements without fully fixing it. Thanks! Leo