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 79BAFC77B7C for ; Thu, 4 May 2023 16:22:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EEC4A900006; Thu, 4 May 2023 12:22:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E9D26900002; Thu, 4 May 2023 12:22:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DB26F900006; Thu, 4 May 2023 12:22:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by kanga.kvack.org (Postfix) with ESMTP id 8E223900002 for ; Thu, 4 May 2023 12:22:21 -0400 (EDT) Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-3062b101ae1so496282f8f.2 for ; Thu, 04 May 2023 09:22:21 -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=1683217340; x=1685809340; 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=Z1OnjivzCbuDtIWEyE2afJXqYqSSN0KhJlhWm5rPWWGauxoOj+2CBkPTS+jKPyUpda dEWM+Ilj18CiuB0LEgGXlQ/4jgqj74bLZBlqcvvJP5jWsqafeFwUc7mwUsgkuiCsIwXC DHhWrM9d2buza8g7Q59Hcw93dn3x4DZeP7tOz0gwCnwFA+ERMTMiwnpgis1e/+gocm/a kkXBYT6yCUAKziNcJF6NvPSgSFtSsRWgZG71F6r8IM4mZcK9IDyo6l5lV5s0la4Sjup1 OgHeIOlFyWstq7lpcY5jnaXEBlTm2dIshLoQIBon4j8Tuo7/lTSFwMXFvgQGir63uRQZ fVLg== X-Gm-Message-State: AC+VfDxHRf8/cEVvj9GvBO4AGlVlvDRzRWeFfFZRn2KgmPDEDcv+DEOB TSP9xfargPtfbRews+0ykx6UjwD/J7DNaPrhOgE1CQ== X-Google-Smtp-Source: ACHHUZ6W7LU6+7sJ+JIBNyUc93OdZBrKmPb6kgAM40ObN2WRJqo/GOAU298MN4AghxYk5WmY9UXzE3DSoSxQENd3Lcc= 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-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 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