Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp778675rwr; Thu, 4 May 2023 09:25:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5UOx963vz8hpPOJlXYGPynclkGwhLt0axtV0BkR7oAbXPkpdJJW78Cv3xHEd1AIOHOLbNm X-Received: by 2002:a05:6a20:7da0:b0:f3:3ea5:5185 with SMTP id v32-20020a056a207da000b000f33ea55185mr3073519pzj.10.1683217538408; Thu, 04 May 2023 09:25:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683217538; cv=none; d=google.com; s=arc-20160816; b=rh+tO6rhFHR+YNN94LtgKSbbXi8bAYmpL6xMG3gJSgxmSAVapOz3rRrQs5YZj4h2yD 6nEu0RPxoXhmnM7EFNDMlxOTIT012JuUZuN8iZB0MyyYDWARm/u5dMJczs9rp0RK7qfi xR5R0MPgtuZ/1P2tGgZ4jWdG5eaQ21IU9E7Wg24Li67nQToH+DVVmG4Z6ver2wOFS0IA ld8O3xCdNzkfDPk7mYDXzLeqBHB84xfKmfQQOyNEd5IF6YXKBMWphC1NYzl3fCB7M2qh Yv+LhGAjGQ2cdvaZl8Lw3q0W6HTyo7i5DoOYsr7EauYI6OcDSdS3Fjwr4ujK5hPd1Vu/ zsIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Gsk62XwjD8JjQowiDifvFLPW2uokrx3QTotNr7V9c/A=; b=FneYRSKsvzs+xsT2Zh9txJQ18Hzk7NKZjxZp1SVkMAKy+nJSAYDa31CLes24i1zpia bLCs+fp+LZvGiOGR53H6IyrOMhVIofphXjuLMwtWnkKKJLMj5//ODiKOe965z4KT5BWN dhE1UsXhb32yl83mbv5ajUqviFbOfzdPppQKSBPBzcB7g1gZeA94NUe8PpwvI7uj2h2H LEvX9tFLTRyYIQu8xEIMFgKwF48Ur6SZGEXe/a3MnRXdPTnQ0cZ4lg3yPcXt7bbV1swH JzPu6iZ+iLzoaY2lcLp2se0VWAdFtDBlC3Xa5E6UBR0p2Nkg7rLlUp6Yw4PIiOoB8nEW HmJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=6NGLeWA3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e13-20020a056a0000cd00b0063473a51539si31150167pfj.398.2023.05.04.09.25.21; Thu, 04 May 2023 09:25:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=6NGLeWA3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229774AbjEDQW2 (ORCPT + 99 others); Thu, 4 May 2023 12:22:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229754AbjEDQWZ (ORCPT ); Thu, 4 May 2023 12:22:25 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CE045B96 for ; Thu, 4 May 2023 09:22:22 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-2f3fe12de15so497756f8f.3 for ; Thu, 04 May 2023 09:22:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683217340; x=1685809340; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Gsk62XwjD8JjQowiDifvFLPW2uokrx3QTotNr7V9c/A=; b=6NGLeWA30bcHwOn4ghW5tWONP3tIeVXLoIAwGSOlF40SYraEbii/SQhzrJIho8Ivb6 Hpkk6vNh9E5t/cw05230dMqe0m+/H6ie+h8h31p+GrZCCgkTxJbXyMjFGjZkhz3bV6dG vSjHZI0HIdPfHSmqobGMchd9amOB1v/ceZjRFhmXUrjm4M4cWFnS99GIAMxh/gj5liXv 4tj0lHTy81/1Wbpb012EhMfXD9LTcX1fI/Tm4TbQO8kVMc6YZQrPrde4R4+RJt2s2OWX VOgAgJHhDqiDK83jUMMdRLdqlv9RhFWhmjzvFXehDDJFCUBnHdRe0JsvmE5LyyU2xx97 symQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683217341; x=1685809341; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Gsk62XwjD8JjQowiDifvFLPW2uokrx3QTotNr7V9c/A=; b=PdjKYqsaKv8qJYcZsy/bIubThsiOQAnb/Aoh24vnZtHwLF+gopow9vEeBB+fpNOUsQ L24ImAOtvwzy+9VNlY+eMsxwkvEhEOGt52zdWQuYNBaU683boUQWBnxzN2CTSHnLMD2E G3O0O1bluHwCziRMi9SC1/J7e9mhXwGhSIKdEKz08w37JmOvkyYj7tC+zmyQfLjDTaKs 2a+5Imb4n87ReMijU0G7qksGwgYft5bCr/4Jkp5ycNbguKHLo0OmdUJFjihy8C+/Kr18 64Lg0c6ajj+eOxY4wMxtl7t+lRlDNZ3qzkaIpnXuI80exma5rQ51vdIuREdFJUTyT5nz Nadw== X-Gm-Message-State: AC+VfDw+I9EVAxfd44GWAW3+krXXmweTJxfZRkxNLUqEgLh77utdAtY3 Ql3HBSuFExqyaA5uvC+tIV/MKSTZtpn9tvE2O5ClkQ== X-Received: by 2002:a05:6000:120a:b0:2fc:7b62:f459 with SMTP id e10-20020a056000120a00b002fc7b62f459mr2840579wrx.32.1683217340407; Thu, 04 May 2023 09:22:20 -0700 (PDT) MIME-Version: 1.0 References: <20230501165450.15352-1-surenb@google.com> <20230501165450.15352-36-surenb@google.com> In-Reply-To: From: Suren Baghdasaryan Date: Thu, 4 May 2023 09:22:07 -0700 Message-ID: Subject: Re: [PATCH 35/40] lib: implement context capture support for tagged allocations To: Michal Hocko Cc: akpm@linux-foundation.org, kent.overstreet@linux.dev, vbabka@suse.cz, hannes@cmpxchg.org, roman.gushchin@linux.dev, mgorman@suse.de, dave@stgolabs.net, willy@infradead.org, liam.howlett@oracle.com, corbet@lwn.net, void@manifault.com, peterz@infradead.org, juri.lelli@redhat.com, ldufour@linux.ibm.com, catalin.marinas@arm.com, will@kernel.org, arnd@arndb.de, tglx@linutronix.de, mingo@redhat.com, dave.hansen@linux.intel.com, x86@kernel.org, peterx@redhat.com, david@redhat.com, axboe@kernel.dk, mcgrof@kernel.org, masahiroy@kernel.org, nathan@kernel.org, dennis@kernel.org, tj@kernel.org, muchun.song@linux.dev, rppt@kernel.org, paulmck@kernel.org, pasha.tatashin@soleen.com, yosryahmed@google.com, yuzhao@google.com, dhowells@redhat.com, hughd@google.com, andreyknvl@gmail.com, keescook@chromium.org, ndesaulniers@google.com, gregkh@linuxfoundation.org, ebiggers@google.com, ytcoode@gmail.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, bristot@redhat.com, vschneid@redhat.com, cl@linux.com, penberg@kernel.org, iamjoonsoo.kim@lge.com, 42.hyeyoo@gmail.com, glider@google.com, elver@google.com, dvyukov@google.com, shakeelb@google.com, songmuchun@bytedance.com, jbaron@akamai.com, rientjes@google.com, minchan@google.com, kaleshsingh@google.com, kernel-team@android.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux.dev, linux-arch@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-modules@vger.kernel.org, kasan-dev@googlegroups.com, cgroups@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 4, 2023 at 1:09=E2=80=AFAM Michal Hocko wrote= : > > On Wed 03-05-23 08:24:19, Suren Baghdasaryan wrote: > > On Wed, May 3, 2023 at 12:39=E2=80=AFAM Michal Hocko = wrote: > > > > > > On Mon 01-05-23 09:54:45, Suren Baghdasaryan wrote: > > > [...] > > > > +struct codetag_ctx *alloc_tag_create_ctx(struct alloc_tag *tag, si= ze_t size) > > > > +{ > > > > + struct alloc_call_ctx *ac_ctx; > > > > + > > > > + /* TODO: use a dedicated kmem_cache */ > > > > + ac_ctx =3D kmalloc(sizeof(struct alloc_call_ctx), GFP_KERNEL)= ; > > > > > > You cannot really use GFP_KERNEL here. This is post_alloc_hook path a= nd > > > that has its own gfp context. > > > > I missed that. Would it be appropriate to use the gfp_flags parameter > > of post_alloc_hook() here? > > No. the original allocation could have been GFP_USER based and you do > not want these allocations to pullute other zones potentially. You want > GFP_KERNEL compatible subset of that mask. Ack. > > But even then I really detest an additional allocation from this context > for every single allocation request. There GFP_NOWAIT allocation for > steckdepot but that is at least cached and generally not allocating. > This will allocate for every single allocation. A small correction here. alloc_tag_create_ctx() is used only for allocations which we requested to capture the context. So, this last sentence is true for allocations we specifically marked to capture the context, not in general. > There must be a better way. Yeah, agree, it would be good to avoid allocations in this path. Any specific ideas on how to improve this? Pooling/caching perhaps? I think kmem_cache does some of that already but maybe something else? Thanks, Suren. > -- > Michal Hocko > SUSE Labs