From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5C8AC28B28 for ; Wed, 12 Mar 2025 16:19:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1BBA4280004; Wed, 12 Mar 2025 12:19:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 16BC6280001; Wed, 12 Mar 2025 12:19:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 00BC1280004; Wed, 12 Mar 2025 12:19:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D776D280001 for ; Wed, 12 Mar 2025 12:19:20 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 7B6FE56A13 for ; Wed, 12 Mar 2025 16:19:22 +0000 (UTC) X-FDA: 83213408964.20.30179A3 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf18.hostedemail.com (Postfix) with ESMTP id EB8D81C0006 for ; Wed, 12 Mar 2025 16:19:19 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=olUsii4b; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=HObC+vVS; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=olUsii4b; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=HObC+vVS; dmarc=none; spf=pass (imf18.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1741796360; a=rsa-sha256; cv=none; b=Ej0zqi/fKfXQsW8+7bzZ9mubPbtM1X/OlG8rGY6FYjHEwuojUi119cqByaaniAjQj3a80w yIaec8ujUqEfY2qPuVP9ABI+nsKQg1FtzRj4Y1x2K78306N/XyVqoJ770+5Ux22CWVA7hM iH+10SjMKwfxIAe4iTBCBtNzYouvKc4= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=olUsii4b; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=HObC+vVS; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=olUsii4b; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=HObC+vVS; dmarc=none; spf=pass (imf18.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1741796360; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=DnTwYGcMdt2yD7Bx/7ZXmsbNs3yi4b7YI/y4yBC4Fcc=; b=mWe45I9zp0/y6A9ZQlrB4om/XAzSbKg/SLo5Sx1b+/EulGvC2jlantFpLEtCWXsciiV2eD UJXEurWvPDC8WAy59IwWxWbrwuepdN7CMFUbjVXvpv0Xmbxh71PNA1joQwuEbeneJxzQY9 0Vd6n6xJa0+wny0jPI14zVl7ngB/bYg= Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 841902118C; Wed, 12 Mar 2025 16:19:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1741796358; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DnTwYGcMdt2yD7Bx/7ZXmsbNs3yi4b7YI/y4yBC4Fcc=; b=olUsii4b7a7IQ8gk3yHHmXLdmnzC4C3L+oJwrgTQLbSdHjxsRO9s41N1phyqM/+IURZ0WG W3jFRBsEGjf0Rr8j4KIoi5Mjhzk98ZqFGshWxFdeJrCBa2A1tdnJSaI5MZezHcIjN/PqQE ezPrhc4l1YQOStgk/vx1rch/bg5NN+8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1741796358; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DnTwYGcMdt2yD7Bx/7ZXmsbNs3yi4b7YI/y4yBC4Fcc=; b=HObC+vVSS/Wpao5eAhBkPwafJLeb5mSTnjwbFmv16/Qe+lUCeqVHdUjlrq2AN8U6kmarji tjffBKarma0bmSBw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1741796358; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DnTwYGcMdt2yD7Bx/7ZXmsbNs3yi4b7YI/y4yBC4Fcc=; b=olUsii4b7a7IQ8gk3yHHmXLdmnzC4C3L+oJwrgTQLbSdHjxsRO9s41N1phyqM/+IURZ0WG W3jFRBsEGjf0Rr8j4KIoi5Mjhzk98ZqFGshWxFdeJrCBa2A1tdnJSaI5MZezHcIjN/PqQE ezPrhc4l1YQOStgk/vx1rch/bg5NN+8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1741796358; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DnTwYGcMdt2yD7Bx/7ZXmsbNs3yi4b7YI/y4yBC4Fcc=; b=HObC+vVSS/Wpao5eAhBkPwafJLeb5mSTnjwbFmv16/Qe+lUCeqVHdUjlrq2AN8U6kmarji tjffBKarma0bmSBw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 504A51377F; Wed, 12 Mar 2025 16:19:18 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id KrvsDga00WeoHQAAD6G6ig (envelope-from ); Wed, 12 Mar 2025 16:19:18 +0000 Message-ID: Date: Wed, 12 Mar 2025 17:19:18 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH RFC v2 02/10] slab: add sheaf support for batching kfree_rcu() operations Content-Language: en-US To: Suren Baghdasaryan Cc: "Liam R. Howlett" , Christoph Lameter , David Rientjes , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Uladzislau Rezki , linux-mm@kvack.org, linux-kernel@vger.kernel.org, rcu@vger.kernel.org, maple-tree@lists.infradead.org References: <20250214-slub-percpu-caches-v2-0-88592ee0966a@suse.cz> <20250214-slub-percpu-caches-v2-2-88592ee0966a@suse.cz> From: Vlastimil Babka In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam07 X-Rspam-User: X-Stat-Signature: pz3cfarki8un937ntahw8gpjafznw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roMNnI4LOUUlGbMWukGZLcAHJHXGWjAaGxciqurPLfiqidQWr1aOaMFJODJfjzb8Ip+5HL/tlI9kMGO75vhiNDeMC7P+Tlz1T8j5XTyDYuWGnrese5nEj8BdS0zjqRLnG70BWbdk1iJSfPaCg/u5Xu2mwBM1DIGGvfqInbHQwgbUh499gyqnLBOJNE/a2nLnVrn/vuLqQNOzQy7vCqWwOF17UaWsQZbPRl1UzYRIqxoLRQbiLi32+IfLgNFaEoZY8XztMcWrJEcw6KlBMT6oqiRdGQ7Y2bl5ILy07c5fBumSsfv0jBg2I7u9G2UIPACiKnoFc1Kc3Nm+a9OoOLL4mZ1xMvwZFVrKTBzrCPFgHA90NtwbkeG6MVjR3yCkCUHSDBjOVqAngDOAmigpO2kVC7VcwMjtT5k0UqvTfkUiZw11PfjwWUid4= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 2/23/25 00:08, Suren Baghdasaryan wrote: > On Fri, Feb 14, 2025 at 8:27 AM Vlastimil Babka wrote: >> >> Extend the sheaf infrastructure for more efficient kfree_rcu() handling. >> For caches with sheaves, on each cpu maintain a rcu_free sheaf in >> addition to main and spare sheaves. >> >> kfree_rcu() operations will try to put objects on this sheaf. Once full, >> the sheaf is detached and submitted to call_rcu() with a handler that >> will try to put in in the barn, or flush to slab pages using bulk free, > > s/in in/it in > >> when the barn is full. Then a new empty sheaf must be obtained to put >> more objects there. >> >> It's possible that no free sheaves are available to use for a new >> rcu_free sheaf, and the allocation in kfree_rcu() context can only use >> GFP_NOWAIT and thus may fail. In that case, fall back to the existing >> kfree_rcu() machinery. >> >> Expected advantages: >> - batching the kfree_rcu() operations, that could eventually replace the >> existing batching >> - sheaves can be reused for allocations via barn instead of being >> flushed to slabs, which is more efficient >> - this includes cases where only some cpus are allowed to process rcu >> callbacks (Android) >> >> Possible disadvantage: >> - objects might be waiting for more than their grace period (it is >> determined by the last object freed into the sheaf), increasing memory >> usage - but the existing batching does that too? >> >> Only implement this for CONFIG_KVFREE_RCU_BATCHED as the tiny >> implementation favors smaller memory footprint over performance. >> >> Signed-off-by: Vlastimil Babka > > Reviewed-by: Suren Baghdasaryan Thanks. >> @@ -2569,6 +2571,24 @@ static void sheaf_flush(struct kmem_cache *s, struct slab_sheaf *sheaf) >> sheaf->size = 0; >> } >> >> +static void __rcu_free_sheaf_prepare(struct kmem_cache *s, >> + struct slab_sheaf *sheaf); >> + >> +static void rcu_free_sheaf_nobarn(struct rcu_head *head) >> +{ >> + struct slab_sheaf *sheaf; >> + struct kmem_cache *s; >> + >> + sheaf = container_of(head, struct slab_sheaf, rcu_head); >> + s = sheaf->cache; > > Ah, that's where you are using sheaf->cache. Maybe you should > introduce it in this patch? Yeah. Will also move the addition of rcu_free to struct slub_percpu_sheaves instead of those TODOs.