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 9C0FEC54E68 for ; Tue, 12 Mar 2024 09:23:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 19C4C8D0022; Tue, 12 Mar 2024 05:23:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 122FD8D000D; Tue, 12 Mar 2024 05:23:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E461D8D0022; Tue, 12 Mar 2024 05:22:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D257E8D000D for ; Tue, 12 Mar 2024 05:22:59 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id AC2261C11A8 for ; Tue, 12 Mar 2024 09:22:59 +0000 (UTC) X-FDA: 81887847678.10.F482D6F Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf06.hostedemail.com (Postfix) with ESMTP id 6FCB0180011 for ; Tue, 12 Mar 2024 09:22:57 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=JjTUxez+; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=4EUcVuLu; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=JjTUxez+; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=4EUcVuLu; spf=pass (imf06.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1710235377; 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=QstBqPw+TFWXqr+lHM3TQAnfI7rBxMjKCBz0FdaAFh8=; b=iQXBlnS88FFmvca2oElMSBXzxtTbVqDO8UsN8Otn4Tk2B/M2CEUslsLVfVH0xpXP7ldwYb pRDVoP1JzTgdV309Y9cQxmrlOuO0tCvW8az8S940G7DIDsPBanya+eQ5YyPoOu647XBxIe Osbssd89I9sU4VpILQGgoVZ174i6XAA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710235377; a=rsa-sha256; cv=none; b=s0l0+HnylHSGbeYOtF5gAesHSV/30PC4t9tbC843Vna4MMDc/7uxaDLaiNbrMf24y+Wnf4 79Xd7i3xbzw+kmDHI92JrPZelQ5iTxe7c7Nil6S9Ke3NY6y9YIE9PWDdkNU4/0Pi8b1k2h rzZFpIoaZ+3dXDHppGZp0d6ZSniCibc= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=JjTUxez+; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=4EUcVuLu; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=JjTUxez+; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=4EUcVuLu; spf=pass (imf06.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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 6A4A6374BE; Tue, 12 Mar 2024 09:22:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1710235375; 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=QstBqPw+TFWXqr+lHM3TQAnfI7rBxMjKCBz0FdaAFh8=; b=JjTUxez+t5+tkgWCeHoYFhbWGQ/8+VyUw3UsPDj4CwE/vP4F1JcUAVotrRQGG7Yyu/yj3B am4oK9MbDA2uZBbKHajOpaLX4c7TyLOFvKXng9vsiDQe/mZGO8kdmNpLDfOda9ZY5Gh2xH ys4+nCE24DEeOg/Y4jnROi95X4GWVCo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1710235375; 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=QstBqPw+TFWXqr+lHM3TQAnfI7rBxMjKCBz0FdaAFh8=; b=4EUcVuLu9y7GiROf+XRXjuTVFaEcC9Oez6BLIMLagRJ2BdV7eDlXozkus+xsGav7jhpWGa KAeVEKkPIQD5NgBQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1710235375; 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=QstBqPw+TFWXqr+lHM3TQAnfI7rBxMjKCBz0FdaAFh8=; b=JjTUxez+t5+tkgWCeHoYFhbWGQ/8+VyUw3UsPDj4CwE/vP4F1JcUAVotrRQGG7Yyu/yj3B am4oK9MbDA2uZBbKHajOpaLX4c7TyLOFvKXng9vsiDQe/mZGO8kdmNpLDfOda9ZY5Gh2xH ys4+nCE24DEeOg/Y4jnROi95X4GWVCo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1710235375; 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=QstBqPw+TFWXqr+lHM3TQAnfI7rBxMjKCBz0FdaAFh8=; b=4EUcVuLu9y7GiROf+XRXjuTVFaEcC9Oez6BLIMLagRJ2BdV7eDlXozkus+xsGav7jhpWGa KAeVEKkPIQD5NgBQ== 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 3A6781364F; Tue, 12 Mar 2024 09:22:55 +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 7vPiDe8e8GW6NAAAD6G6ig (envelope-from ); Tue, 12 Mar 2024 09:22:55 +0000 Message-ID: <8aa61329-dc3c-46f2-9db5-6e0770fbedda@suse.cz> Date: Tue, 12 Mar 2024 10:22:54 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH RFC 4/4] UNFINISHED mm, fs: use kmem_cache_charge() in path_openat() To: Roman Gushchin , Linus Torvalds Cc: Josh Poimboeuf , Jeff Layton , Chuck Lever , Kees Cook , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Johannes Weiner , Michal Hocko , Shakeel Butt , Muchun Song , Alexander Viro , Christian Brauner , Jan Kara , linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-fsdevel@vger.kernel.org References: <20240301-slab-memcg-v1-0-359328a46596@suse.cz> <20240301-slab-memcg-v1-4-359328a46596@suse.cz> Content-Language: en-US From: Vlastimil Babka In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spamd-Bar: / X-Stat-Signature: txtz3tpm6dzkqhiwt6uwyiqpud7an9jz X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 6FCB0180011 X-Rspam-User: X-HE-Tag: 1710235377-66809 X-HE-Meta: U2FsdGVkX19hEiCRd0nNQyQwcf44dSKF+oWTpVpoaBm4ya+mlY3Ow6Q4lLMvctfqoMFA225dWKjaig3s+g+mFstik9bKLXRjWC/pkm5iWHB9w9sj86w7EuLK+vsHB4Lyh/MZMb64SW4bC95mYw5I5WAQANFYzJuZB7mVFTP8wtJpggJsilUaTE5zCxT/yfDQxOVv9Tz47gcNldnqYxtw6jCjNBqmfM9/j7qK31H2V6Y906hRecjTNdBlQkTClvREWTKSpbwQex3xzZDRbmrGps4Af8DH5aMjMcbTxmNcVkDhhOOeu+dbKJAWVHZNakc8KN2EbUH9FBQQKaKacpSMUGY5gsoQqPsoYGS3tB7dD9TsLOMQmMkB56S+DDtETtaFBGDbiX31lvMS/NneM9StxpfTTWvn1ViNrHbfHfiOn6WsOblVZ02iYmaxGTc7v/vbTRaPAzQxrx07MzW3GtOieIsgVtMdCHjYI13gwGn/avygnyCgUop9ViGVQhmuR9nenxubD4i4yMr47CL8BtM4MesEjdqIkdjCcz0Zydd4066wlfeTUegYN7X+1EEjAwOPCDygDg7wCnQMgTYrTwDjZ6cYdMebMGfASKvxW4K2kROKMT1uqnzbuDezZyo7ikFkb/ocVlYeF0haNHqKRRgwx3buBqwb9hZgAh1CaojmKp57ZFVh9AdAhS5ZwukcXcCx4f5VjHTKTN+XFVfxCG1T5tPbrbm1TK+geJ475Ii3CQ+7cp8f6IcL0xXnYgKIa5QJfNNNvZWl0am1Anz5MstYSf+gdZSWWjSj69kkxE8mjxGBYX6cVQ9wsjBWni+DLUFmc+uQWxoyzJNl2iUey97kDwP4J/rfKupzgn/0vprA/esMrm2TVoWS2hamgK6Z+V1oSK9OXOtDYEFbv/GSZ8MRP/UyMUU4gWcvpH/evN6Thyu3MCw2Ms2quMCBl/0riDsIUv3+ql9OLQ/O1EA+yxI uahyf3jk riCfoLSoeWpnShDKMxLb0R6dgonYR5MCgn04YsKNg1XP2qUUl40j0RDEB5Visn9ZhW0wm8GuGMSEps3Nzw6lZ6VCV6A== 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 3/1/24 19:53, Roman Gushchin wrote: > On Fri, Mar 01, 2024 at 09:51:18AM -0800, Linus Torvalds wrote: >> What I *think* I'd want for this case is >> >> (a) allow the accounting to go over by a bit >> >> (b) make sure there's a cheap way to ask (before) about "did we go >> over the limit" >> >> IOW, the accounting never needed to be byte-accurate to begin with, >> and making it fail (cheaply and early) on the next file allocation is >> fine. >> >> Just make it really cheap. Can we do that? >> >> For example, maybe don't bother with the whole "bytes and pages" >> stuff. Just a simple "are we more than one page over?" kind of >> question. Without the 'stock_lock' mess for sub-page bytes etc >> >> How would that look? Would it result in something that can be done >> cheaply without locking and atomics and without excessive pointer >> indirection through many levels of memcg data structures? > > I think it's possible and I'm currently looking into batching charge, > objcg refcnt management and vmstats using per-task caching. It should > speed up things for the majority of allocations. > For allocations from an irq context and targeted allocations > (where the target memcg != memcg of the current task) we'd probably need to > keep the old scheme. I hope to post some patches relatively soon. Do you think this will work on top of this series, i.e. patches 1+2 could be eventually put to slab/for-next after the merge window, or would it interfere with your changes? > I tried to optimize the current implementation but failed to get any > significant gains. It seems that the overhead is very evenly spread across > objcg pointer access, charge management, objcg refcnt management and vmstats. > > Thanks!