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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8B1EC4332F for ; Sun, 9 Jan 2022 06:22:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235208AbiAIGWB (ORCPT ); Sun, 9 Jan 2022 01:22:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229960AbiAIGWA (ORCPT ); Sun, 9 Jan 2022 01:22:00 -0500 Received: from mail-yb1-xb31.google.com (mail-yb1-xb31.google.com [IPv6:2607:f8b0:4864:20::b31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2E86C06173F for ; Sat, 8 Jan 2022 22:21:59 -0800 (PST) Received: by mail-yb1-xb31.google.com with SMTP id p5so22187550ybd.13 for ; Sat, 08 Jan 2022 22:21:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7MHOoZalZ4yzdXRz8I2/T4uac/wUxMGeLB4SbnbuPrk=; b=E0CjwfS0akiynM70MG+cOaaLmR+MLPa5cimWRH++WIDvhMf8SNXD6+Ce+k86NXuhHe Bpjc/YIFX0whSU8iyb5UwnoIqPW0+KheS1Ta0solvIEE/OXwqcLbeSLi2ynZm6JX5uZK r43biAwgdy2lKh9uqKPl+Wcpux/0SwkCI+ZaI8upAedJ2QX2Dg0VtaXtCsofOk7pSVoa av18a9k08ZqjeCsmIAhlqZIPUz4wnApQ8DCMjG6jSeothuRUF9Hgn/rVvkyY8SnAOLIX ZRaP8hTxlaH+RVc4hXGQGT3UVPHzAMIOs9v4HAr6wXJm35qWlalg3XFz21lJCLIoj4RW VwmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7MHOoZalZ4yzdXRz8I2/T4uac/wUxMGeLB4SbnbuPrk=; b=D0C+bIlBbJmKo9HEqApaZFFTjpQKYEz7cUPMN+RqnEmUBJMCRgsZT19wwCBHCQg236 RRxw9TCcEJNvD6g8txobl7Z3K8mTLjOHqRjT51yJ3bod2+ofPSTZ8lRXE2cCjHOiiUAY PpnALfMZzxbTZn0lyfsAop77b+N6u2HUfxrLlGIRULUb2cPaj4xcIe+m1a6YU/N3ibqu TuuQxKSFKFDF1DOy97mxwTjD7ahzTUsyag7UvZiUkMGWOejpnJDmxvQUC3SPcZwyg5lx lzRjPe3/yw50boJMCswUOB3ljGfNTDOzyLisxuyvENzFIW2cCLhgRo8FZMaVvXZdAO+N V4KA== X-Gm-Message-State: AOAM532xw6odxnTYVU+OpBNGMqAX/VGlNmlAlUF2oPrs/MY9IMgxGJAM 4wcdGwPNgJP8R/F7K4qt1LMc+7gMklnoo9Qdp9EIVg== X-Google-Smtp-Source: ABdhPJyZ+bU4mbb0+w9+kdvDUEc5jYGIsxWWLUHnc0CSRRjhs5Oh0+esW/JLryFaRopClBiW67hA/1+sdioiJ76IOfs= X-Received: by 2002:a25:3890:: with SMTP id f138mr79980398yba.703.1641709318562; Sat, 08 Jan 2022 22:21:58 -0800 (PST) MIME-Version: 1.0 References: <20211220085649.8196-1-songmuchun@bytedance.com> <20211220085649.8196-3-songmuchun@bytedance.com> In-Reply-To: From: Muchun Song Date: Sun, 9 Jan 2022 14:21:22 +0800 Message-ID: Subject: Re: [PATCH v5 02/16] mm: introduce kmem_cache_alloc_lru To: Roman Gushchin 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 , Vlastimil Babka Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Thanks.