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 E0155C4332F for ; Tue, 11 Jan 2022 15:41:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3C28E6B008A; Tue, 11 Jan 2022 10:41:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 34A826B008C; Tue, 11 Jan 2022 10:41:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C5186B0092; Tue, 11 Jan 2022 10:41:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0189.hostedemail.com [216.40.44.189]) by kanga.kvack.org (Postfix) with ESMTP id 059116B008A for ; Tue, 11 Jan 2022 10:41:33 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id A93EA9274E for ; Tue, 11 Jan 2022 15:41:32 +0000 (UTC) X-FDA: 79018420824.26.21031B6 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf29.hostedemail.com (Postfix) with ESMTP id 14AE9120015 for ; Tue, 11 Jan 2022 15:41:31 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 46A01212C5; Tue, 11 Jan 2022 15:41:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1641915690; 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=uaeh72LNlQ3FJmzxxlOZxQSkNAPJwZlxowsmMRMGMVw=; b=QkQUdB1pCGs/AozhrpVo4RO6hfCBm6mA+j0o8+QY4VPSLEad2gkLp9Z2Zi6FGKeVFOCFAB 1OIvfzfl9W3skPYEfJdcMqd6gu8dngI/GnVkd61ailOGuV+7R3wG1XeSD4fIBOsqatOtN6 1S/hNCI5G+xKbJnqrpraVfeuQ5F6Y5w= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1641915690; 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=uaeh72LNlQ3FJmzxxlOZxQSkNAPJwZlxowsmMRMGMVw=; b=yBs8AXrIO0pErgyQ4ypZm16jOB6JLTDyBoA6X3+KnQrptNo4hhneCtYwt/YVp/N8tTIYBx ewwPgGirOQl+rMAw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id DC9D913ADE; Tue, 11 Jan 2022 15:41:29 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id E8oVNSml3WHRFAAAMHmgww (envelope-from ); Tue, 11 Jan 2022 15:41:29 +0000 Message-ID: Date: Tue, 11 Jan 2022 16:41:29 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.1 Content-Language: en-US To: Roman Gushchin , Muchun Song Cc: Matthew Wilcox , Andrew Morton , Johannes Weiner , Michal Hocko , Vladimir Davydov , Shakeel Butt , Yang Shi , Alex Shi , Wei Yang , Dave Chinner , trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, jaegeuk@kernel.org, chao@kernel.org, Kari Argillander , linux-fsdevel , LKML , Linux Memory Management List , linux-nfs@vger.kernel.org, Qi Zheng , Xiongchun duan , Fam Zheng , Muchun Song , Christoph Lameter , Pekka Enberg , David Rientjes References: <20211220085649.8196-1-songmuchun@bytedance.com> <20211220085649.8196-3-songmuchun@bytedance.com> From: Vlastimil Babka Subject: Re: [PATCH v5 02/16] mm: introduce kmem_cache_alloc_lru In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 14AE9120015 X-Stat-Signature: u9pczn5kump97s8qagb6whfxr9teijyg Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=QkQUdB1p; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=yBs8AXrI; spf=pass (imf29.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none X-Rspamd-Server: rspam07 X-HE-Tag: 1641915691-142105 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: On 1/10/22 19:47, Roman Gushchin wrote: > On Sun, Jan 09, 2022 at 02:21:22PM +0800, Muchun Song wrote: >> On Fri, Jan 7, 2022 at 11:05 AM Roman Gushchin wrote: >> > >> [...] >> > > /* >> > > * struct kmem_cache related prototypes >> > > @@ -425,6 +426,8 @@ static __always_inline unsigned int __kmalloc_index(size_t size, >> > > >> > > void *__kmalloc(size_t size, gfp_t flags) __assume_kmalloc_alignment __alloc_size(1); >> > > void *kmem_cache_alloc(struct kmem_cache *s, gfp_t flags) __assume_slab_alignment __malloc; >> > > +void *kmem_cache_alloc_lru(struct kmem_cache *s, struct list_lru *lru, >> > > + gfp_t gfpflags) __assume_slab_alignment __malloc; >> > >> > I'm not a big fan of this patch: I don't see why preparing the lru >> > infrastructure has to be integrated that deep into the slab code. >> > >> > Why can't kmem_cache_alloc_lru() be a simple wrapper like (pseudo-code): >> > void *kmem_cache_alloc_lru(struct kmem_cache *s, struct list_lru *lru, >> > gfp_t gfpflags) { >> > if (necessarily) >> > prepare_lru_infra(); >> > return kmem_cache_alloc(); >> > } >> >> Hi Roman, >> >> Actually, it can. But there is going to be some redundant code similar >> like memcg_slab_pre_alloc_hook() does to detect the necessity of >> prepare_lru_infra() in the new scheme of kmem_cache_alloc_lru(). >> I just want to reduce the redundant overhead. > > Is this about getting a memcg pointer? > I doubt it's a good reason to make changes all over the slab code. > Another option to consider adding a new gfp flag. I'm not sure how a flag would help as it seems we really need to pass a specific list_lru pointer and work with that. I was thinking if there was only one list_lru per class of object it could be part of struct kmem_cache, but investigating kmem_cache_alloc_lru() callers I see lru parameters: - &nfs4_xattr_cache_lru - this is fixed - xas->xa_lru potentially not fixed, although the only caller of xas_set_lru() passes &shadow_nodes so effectively fixed - &sb->s_dentry_lru - dynamic, boo > Vlastimil, what do you think? Memcg code is already quite intertwined with slab code, for better or worse, so I guess the extra lru parameter in a bunch of inline functions won't change much. I don't immediately see a better solution. > Thanks! >