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 BFFA4C433F5 for ; Wed, 19 Jan 2022 06:31:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 154EC6B0071; Wed, 19 Jan 2022 01:31:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 104DD6B0073; Wed, 19 Jan 2022 01:31:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EE6B16B0074; Wed, 19 Jan 2022 01:31:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0150.hostedemail.com [216.40.44.150]) by kanga.kvack.org (Postfix) with ESMTP id DD2A56B0071 for ; Wed, 19 Jan 2022 01:31:13 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 96692181D6059 for ; Wed, 19 Jan 2022 06:31:13 +0000 (UTC) X-FDA: 79046064426.15.E38F2DD Received: from mail-il1-f169.google.com (mail-il1-f169.google.com [209.85.166.169]) by imf29.hostedemail.com (Postfix) with ESMTP id 44E36120004 for ; Wed, 19 Jan 2022 06:31:12 +0000 (UTC) Received: by mail-il1-f169.google.com with SMTP id o10so1387055ilh.0 for ; Tue, 18 Jan 2022 22:31:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=UkxAceZxhajO8BZgkx8KrSGLctag3Zj1oQU14fV01lI=; b=Al/uDi3lg+lN09USLdsbvITyPec67cN5Pi0OUqyCegJg47rd3VhCxspvMZpaV1wT+W SvDRoVhrHnzyuI9uW2Gx6O40x+11XZAEE1mWZ2oDkglCgZRBiuLMienpZwn1dXxuVxZa dVER1xf43OOVYL6tGrvttn0OgbDIUhu2z6BmdN4oPcA1YVTj2vsPuDVyX9N8naFPXLpf s43BvSzaDQpikXXCfDezMayLfKPfhBl4huxVeq4LT9q+BZkxCufxE84ehwGoJ6Eqw0RG d9oaa2p0Itw0RYje0YB8rgjkFpskE4CAwxsTR9a91PU+sHdLdt5Xk2nrxm0O8qiCQohR q4+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=UkxAceZxhajO8BZgkx8KrSGLctag3Zj1oQU14fV01lI=; b=27z7BlOwfYBLcE53mTZd8rNSZQFwn1juZRAoMAg0tOyCrhTrNn1di2MmMHTtqEBZc+ UNsSwN29R76Qyjq4/mYE3bXxHx7EHZPlCbEU/J/bltnd/dKqp/yidTtJnYSa13fSHbXc lQs2Jb5s/EpK6hAYu1svsrj+dTQ8YAMlzHvxK0eDx7TyF0yfNZRYwBYwlOSo2VIOR7mw vY1lTSkDrRRxXFiTBcsEXuiXhENqUdqJPw/8YV4unLHKPk7kkIpAxoLDC0tsMn0SysG8 sflKZTkYM2+XH1airCiLZalbDNTy/WjDx1pn4TZw3lOtZjz870DidxSsXaqyXa39YheF Z3cA== X-Gm-Message-State: AOAM532AlsXv1oquLyr+9COZEBlis9FJ4D1XTUYhI5BQFczIPp274qMM 1ZdGSiQhh9728fVTGe+Au5zjyA== X-Google-Smtp-Source: ABdhPJx6MTLpNNm2sOsjZA6EPUjb9C5/VI8R+cN1990w1Y2oviGcshouM6+huqzkXNgC6iBpgogcAg== X-Received: by 2002:a05:6e02:198a:: with SMTP id g10mr15789393ilf.280.1642573872028; Tue, 18 Jan 2022 22:31:12 -0800 (PST) Received: from google.com ([2620:15c:183:200:90fc:e0c9:c69f:bede]) by smtp.gmail.com with ESMTPSA id g5sm13398294ioo.21.2022.01.18.22.31.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jan 2022 22:31:11 -0800 (PST) Date: Tue, 18 Jan 2022 23:31:07 -0700 From: Yu Zhao To: Michal Hocko Cc: Andrew Morton , Linus Torvalds , Andi Kleen , Catalin Marinas , Dave Hansen , Hillf Danton , Jens Axboe , Jesse Barnes , Johannes Weiner , Jonathan Corbet , Matthew Wilcox , Mel Gorman , Michael Larabel , Rik van Riel , Vlastimil Babka , Will Deacon , Ying Huang , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, page-reclaim@google.com, x86@kernel.org, Konstantin Kharlamov Subject: Re: [PATCH v6 6/9] mm: multigenerational lru: aging Message-ID: References: <20220104202227.2903605-1-yuzhao@google.com> <20220104202227.2903605-7-yuzhao@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 44E36120004 X-Stat-Signature: s89yw7oit4757tcod944qjf4wd7brnzo Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="Al/uDi3l"; spf=pass (imf29.hostedemail.com: domain of yuzhao@google.com designates 209.85.166.169 as permitted sender) smtp.mailfrom=yuzhao@google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam07 X-HE-Tag: 1642573872-124364 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, Jan 13, 2022 at 01:02:26PM +0100, Michal Hocko wrote: > On Thu 13-01-22 02:43:38, Yu Zhao wrote: > [...] > > > > The bottom line is I can try various optimizations, e.g., preallocate > > > > a few buffers for a limited number of page walkers and if this number > > > > has been reached, fallback to the rmap-based function. But I have yet > > > > to see evidence that calls for additional complexity. > > > > > > I would disagree here. This is not an optimization. You should be > > > avoiding allocations from the memory reclaim because any allocation just > > > add a runtime behavior complexity and potential corner cases. > > > > Would __GFP_NOMEMALLOC address your concern? It prevents allocations > > from accessing the reserves even under PF_MEMALLOC. > > __GFP_NOMEMALLOC would deal with the complete memory depletion concern > for sure but I am not sure how any of these allocations would succeed > when called from the direct reclaim. Some access to memory reserves is > necessary if you insist on allocating from the reclaim process. > > You can have a look at the limited memory reserves access by oom victims > for an example of how this can be done. Thanks. I'll change GFP_KERNEL to __GFP_HIGH | __GFP_NOMEMALLOC. __GFP_HIGH allows some access to memory reserves and __GFP_NOMEMALLOC prevents the complete depletion. Basically the combination lower the min watermark by 1/2, and we have been using them for add_to_swap_cache().