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 9A869C48BF6 for ; Tue, 27 Feb 2024 00:55:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0B3BE6B0209; Mon, 26 Feb 2024 19:55:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 061FB6B020A; Mon, 26 Feb 2024 19:55:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E45256B020B; Mon, 26 Feb 2024 19:55:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id D18186B0209 for ; Mon, 26 Feb 2024 19:55:32 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 99956C0AD6 for ; Tue, 27 Feb 2024 00:55:32 +0000 (UTC) X-FDA: 81835765704.05.B04F7B6 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf21.hostedemail.com (Postfix) with ESMTP id 0AD2F1C0013 for ; Tue, 27 Feb 2024 00:55:30 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=P9+xpM4a; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf21.hostedemail.com: domain of "SRS0=xPBP=KE=paulmck-ThinkPad-P17-Gen-1.home=paulmck@kernel.org" designates 139.178.84.217 as permitted sender) smtp.mailfrom="SRS0=xPBP=KE=paulmck-ThinkPad-P17-Gen-1.home=paulmck@kernel.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708995331; h=from:from:sender:reply-to: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=4ArQv2GAbwFVhH/4dECGYmUlGta45W0Xdkub1k0kqeQ=; b=fp6tWmz/5R5JQ9CY6FgIbtxji1YfflRGO7/U2TmI/dUxLMcPYu6ka59QEGtfIzuqUv41UW INEOE1MVO3veU1y74B329gl7IlbB+Cpvof+BBWse60KAu0UuG/Iq+9yOfECl0kGei5XqGu ufV8TR7k6gDFi3g57QzhPjRisV/sYF8= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=P9+xpM4a; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf21.hostedemail.com: domain of "SRS0=xPBP=KE=paulmck-ThinkPad-P17-Gen-1.home=paulmck@kernel.org" designates 139.178.84.217 as permitted sender) smtp.mailfrom="SRS0=xPBP=KE=paulmck-ThinkPad-P17-Gen-1.home=paulmck@kernel.org" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708995331; a=rsa-sha256; cv=none; b=F++O96tzgj9U38EXe+deUwSRTbOZg80uoYoFKfu2lmWYwmEJhTBNDPSVMWZspkE2gkj/UN naWaU+dh+nbfpcoqLuu5FiIgW3viIUg/y5oODuoJvO0tZPTPEq+4/CfYikwzdf5nxkrzE8 FVobMy3BYXz6XSqV8d2D36Rj3Bbnr7k= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 2289861360; Tue, 27 Feb 2024 00:55:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BBC80C433F1; Tue, 27 Feb 2024 00:55:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708995329; bh=u4jebG4Kb1YXhFjNl6sDu0rFGKvBtxVeWgU5fnkhOmA=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=P9+xpM4aSwMQka9mbjhR0iQY69bxxNzcGq1cR9uyJl85W+66620o/eBdHFErwZ0ZX AuZ8e9WngWOWTq4Yxd/sUh0cvPQ6GylklTok+54Jtzl7meLwxfQnAhx5O2Np8N/Kn/ lB+xa5Abw/AhUQV4p6jt/aaTLf5+xauhh0wnGo+8JqDWbwTygKPusOTuyaewIaPrDh Efo2PujaoRdx6RU/lnu2vuAg2p57e0A7JYfSA5QeUFvNC5HPME7wIqZeO+tROrwKpG L0aaiTKFu9vRr5NxyqmLFlZo6KHAqsHLMVIVyvl/lOJfgnr6Y7ewNmJ53KHVeoYZvH Voi34F+meqDWA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 693B2CE1147; Mon, 26 Feb 2024 16:55:29 -0800 (PST) Date: Mon, 26 Feb 2024 16:55:29 -0800 From: "Paul E. McKenney" To: Kent Overstreet Cc: Matthew Wilcox , Linus Torvalds , Al Viro , Luis Chamberlain , lsf-pc@lists.linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-mm , Daniel Gomez , Pankaj Raghav , Jens Axboe , Dave Chinner , Christoph Hellwig , Chris Mason , Johannes Weiner Subject: Re: [LSF/MM/BPF TOPIC] Measuring limits and enhancing buffered IO Message-ID: <49354148-4dea-4c89-b591-76b21ed4a5d1@paulmck-laptop> Reply-To: paulmck@kernel.org References: <5c6ueuv5vlyir76yssuwmfmfuof3ukxz6h5hkyzfvsm2wkncrl@7wvkfpmvy2gp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 0AD2F1C0013 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: qygooeuh4ikyehdhd8k67p7u8my4yb43 X-HE-Tag: 1708995330-396904 X-HE-Meta: U2FsdGVkX18a9Ye7ptA5N89pxZFFIaIokoU/CGScNwH3ce0At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fDFT9eQvjCqQ727VAXp8Eb3TOsaYJJEQwLJO/QGx1IhyppbdM/8nS0+vunoi5adk31AaZUxt7GD+B37TdpTXBQfjX2GXWbxVKNFzYTUObqEAatT1gP2gw2e7Y5LVWaU64= 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 Mon, Feb 26, 2024 at 07:29:04PM -0500, Kent Overstreet wrote: > On Mon, Feb 26, 2024 at 04:05:37PM -0800, Paul E. McKenney wrote: > > On Mon, Feb 26, 2024 at 06:29:43PM -0500, Kent Overstreet wrote: > > > Well, we won't want it getting hammered on continuously - we should be > > > able to tune reclaim so that doesn't happen. > > > > > > I think getting numbers on the amount of memory stranded waiting for RCU > > > is probably first order of business - minor tweak to kfree_rcu() et all > > > for that; there's APIs they can query to maintain that counter. > > > > We can easily tell you the number of blocks of memory waiting to be freed. > > But RCU does not know their size. Yes, we could ferret this on each > > call to kmem_free_rcu(), but that might not be great for performance. > > We could traverse the lists at runtime, but such traversal must be done > > with interrupts disabled, which is also not great. > > > > > then, we can add a heuristic threshhold somewhere, something like > > > > > > if (rcu_stranded * multiplier > reclaimable_memory) > > > kick_rcu() > > > > If it is a heuristic anyway, it sounds best to base the heuristic on > > the number of objects rather than their aggregate size. > > I don't think that'll really work given that object size can very from < > 100 bytes all the way up to 2MB hugepages. The shrinker API works that > way and I positively hate it; it's really helpful for introspection and > debugability later to give good human understandable units to this > stuff. You might well be right, but let's please try it before adding overhead to kfree_rcu() and friends. I bet it will prove to be good and sufficient. > And __ksize() is pretty cheap, and I think there might be room in struct > slab to stick the object size there instead of getting it from the slab > cache - and folio_size() is cheaper still. On __ksize(): * This should only be used internally to query the true size of allocations. * It is not meant to be a way to discover the usable size of an allocation * after the fact. Instead, use kmalloc_size_roundup(). Except that kmalloc_size_roundup() doesn't look like it is meant for this use case. On __ksize() being used only internally, I would not be at all averse to kfree_rcu() and friends moving to mm. The idea is for kfree_rcu() to invoke __ksize() when given slab memory and folio_size() when given vmalloc() memory? Thanx, Paul