From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 69C87213E89 for ; Fri, 24 Jul 2026 04:55:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784868933; cv=none; b=NCDPKFfsryNKLRMk5Tf9ZDYRbrnf37tm0anfZQQV3QC5fFGZtDpQxX7VIfbTqWUw5EDnmK94kHCY8fDTAIneL6oEfUzYbsn3QYRQEMyfFNxTLMzOLEQyOhCMQOy4Bn0iXHGsL26MiymSSEVirHaEUuZhxQbe4y+6MGR+zOzz2SM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784868933; c=relaxed/simple; bh=/gqbHGsE0JX75ltZcJZ0/LutdTeo5mLTtiE0fkCflDE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Aiagvk1FmznveYQVDKEgvpJt0rFeLtzkxL6uyMuEWcjyNo01iHLXkAdHDM8ezt57kMIIHaY0Jzu2HxCZ958v7KDoxmGDRNYJ8zYyR6zAt8r8cw92vrzSvqwaUQliqj+w4vmm6zhvOOZKlYChir9pA3NCIkWdBU2D0GuTRZTiQm4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=TuPw3R7a; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="TuPw3R7a" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2cea3004256so643195ad.0 for ; Thu, 23 Jul 2026 21:55:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1784868932; x=1785473732; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=/mymr4wOyF1eBzp+BDc9Q36kn6q3UnnG+2ist6zjbpA=; b=TuPw3R7av7Pmq0ipVZL7E6AaZ4Sby46m9TCeTKSHICPa+e/yCD+NdLYfgb4YveVFOi pghtYAF1VUHXbukYPJZcAXtp1GYuTDLnYFMF/vZkRJAsClR7OUmFYvfYuhyINxveg4QG hUVsdRCAs7LYbKiHSg4UBPx0TIQuNOKKGvqDo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784868932; x=1785473732; h=in-reply-to:content-disposition:content-type: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 :content-type; bh=/mymr4wOyF1eBzp+BDc9Q36kn6q3UnnG+2ist6zjbpA=; b=anrJdXJ+axeeJhZnjw1ArQLi+EdJoqboy7rP3r8LIEG5jd65Q0CDWy4UmQxkRy80nl 1inVaItikW2lvvSHmhgvxOkSnLHb50+3wDhw40AGyMOxd1NenUN473BaXqiCf3U4OBYv NMCeDxX4mQIxHm7cnCoRgiljfQOzCBkDFFaMTg5FbJOGLmzztW6r+2/ff+LU3URhJMbf qGtTj47qFOJYCpvJ+qbAZx7DYG3SPZswcye2HxLTBmfU0wZ+95W3+ay6Iw1vXEIeQ2hv aPRezfqTvK2z/q/xXx28/XwYcJ4RzzKwwRR3pyq0q7Olox9ihgRhUDEEAMJNcVhEGPW/ q3Tg== X-Gm-Message-State: AOJu0YzP1pEqh4hCNjgSpfQt5jqDnipjE8fFw8602/URRNjPG4Tc1K2J 9sNl9KROQvnIl7Z/NFj9O6D+5ZRdlq2T27hQ+sGxqjYxxwYcIIGHkVb85WLtNobNVw== X-Gm-Gg: AR+sD11buLFV/nmWU+8aAoJqEBw4ck2IArvX3ke9yOgaccKxdfiQ356eY0keGXoyFTB wcPn4p7q0nllgoRu3eynyvmwVeLIsqFyNOu4GtHJveSqj1zjjgC7/mGYNVIMKFPkNJ1Z3offPHi nxf+YeDIlUdNZ3Npgy/nnIdPlOgWrf8dQadMkDANQyual6abcCCLjhP7h75R5iHvmlfHi3MRwf2 iiCJjyjoSLTbEYepJuFtRRHKF8Q5+RAu6zqQ4zVpJ4KB9gTDg/qATymNN/qh9TBtN2UXatIau8Q igma2io6dbPdQ//5lN8aiwPCnKK9M/HmfOiDdIkUs4Ay4qIRN8BnGmYLk9Zi2L7JqyJUgEtX2R4 RhfbjeAiOIxbeJ4JnawPWa8zavag+4651PIzaXhJZ5gW+jrR7H+5XdBXn7qkyDqmNeJAtx5mwuO TsMJe9nteEN7C/qS5EXpllKYk8oo1ywaJ5ZmsM05MSkkcp8IDs8cin X-Received: by 2002:a17:903:468e:b0:2c9:fbde:ab66 with SMTP id d9443c01a7336-2cfa6c72079mr67795515ad.37.1784868931715; Thu, 23 Jul 2026 21:55:31 -0700 (PDT) Received: from google.com ([2a00:79e0:2031:6:c102:f12d:5168:6be5]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2cf8efd76cfsm45209895ad.20.2026.07.23.21.55.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2026 21:55:31 -0700 (PDT) Date: Fri, 24 Jul 2026 13:55:26 +0900 From: Sergey Senozhatsky To: Andrew Morton , Wenchao Hao Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Minchan Kim , Sergey Senozhatsky , Nhat Pham , Joshua Hahn , Barry Song , Wenchao Hao Subject: Re: [PATCH v6 0/4] mm/zsmalloc: reduce lock contention in zs_free() Message-ID: References: <20260626015003.2965881-1-haowenchao22@gmail.com> <20260627213600.eb072ba84382807a8242efc9@linux-foundation.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: <20260627213600.eb072ba84382807a8242efc9@linux-foundation.org> Apologies for the delay. On (26/06/27 21:36), Andrew Morton wrote: [..] > > Raspberry Pi 4B (4-core ARM64 Cortex-A72): > > > > mode Base Patched Speedup > > single 59.0ms 56.0ms 1.05x > > multi 2p 94.6ms 66.7ms 1.42x > > multi 4p 202.9ms 110.6ms 1.83x > > > > x86 (20-core Intel i7-12700, 16 concurrent processes): > > > > mode Base Patched Speedup > > single 11.7ms 9.8ms 1.19x > > multi 2p 24.1ms 17.2ms 1.40x > > multi 4p 63.0ms 45.3ms 1.39x > > Well that's a nice result. Indeed. > Sashiko AI review said .... nothing. I don't recall seeing that > before ;) grep-ing the code, I wonder if we maybe want to tweak some comments. Namely, zs_page_migrate() says: The pool migrate_lock protects the race between zpage migration and zs_free which is not entirely true anymore, as zs_free() has a lockless path that doesn't take pool look (when ZS_OBJ_CLASS_BITS permit). Likewise, __zs_compact() says the following about pool migrate_lock: protect the race between zpage migration and zs_free None of these are critical, very minor. Reviewed-by: Sergey Senozhatsky Tested-by: Sergey Senozhatsky Unrelated to the series, no need to do anything. Just because I'm looking at zs_page_migrate() at the moment, would something like this make sense: --- diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 3d566a3ee96f..a6ca93ea1eb2 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -1875,6 +1875,18 @@ static int zs_page_migrate(struct page *newpage, struct page *page, * the class lock protects zpage alloc/free in the zspage. */ spin_lock(&class->lock); + + /* + * Migrating an empty zspage is probably pointless as it's likely + * scheduled for a destruction anyway. + */ + if (!get_zspage_inuse(zspage)) { + spin_unlock(&class->lock); + write_unlock(&pool->lock); + /* Same jusitification as below - we cannot return -EAGAIN. */ + return -EBUSY; + } + /* the zspage write_lock protects zpage access via zs_obj_read/write() */ if (!zspage_write_trylock(zspage)) { spin_unlock(&class->lock);