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 5338CC433F5 for ; Thu, 6 Jan 2022 21:41:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A514F6B0072; Thu, 6 Jan 2022 16:41:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A013B6B0073; Thu, 6 Jan 2022 16:41:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8C8CF6B0074; Thu, 6 Jan 2022 16:41:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0244.hostedemail.com [216.40.44.244]) by kanga.kvack.org (Postfix) with ESMTP id 7F3C16B0072 for ; Thu, 6 Jan 2022 16:41:18 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 3EBB193D93 for ; Thu, 6 Jan 2022 21:41:18 +0000 (UTC) X-FDA: 79001183436.24.B9EC07C Received: from mail-il1-f180.google.com (mail-il1-f180.google.com [209.85.166.180]) by imf24.hostedemail.com (Postfix) with ESMTP id 439DD180007 for ; Thu, 6 Jan 2022 21:41:09 +0000 (UTC) Received: by mail-il1-f180.google.com with SMTP id d14so3163261ila.1 for ; Thu, 06 Jan 2022 13:41:17 -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=VE61gMKhpnWZvU6qcog2kgqC/TE+2QO5LS6iHCKhdqo=; b=X5251x9gOvT9jJO0fIYrghZ2dmsDZAjI/XaWW0c5hgerIpNSgvl0jSew1p/PD5Wl19 Vty9fxDz85jiNwo2PyrzeAVr0Qh4AvnoRBKBwKjqqN+gzpApKSZBr6PBW1Haplrbva6W fgVBMIb7yopx0RKQtKxR50gNsFKTWHXlfqc8oQFDrabFDnXtqIegt0iG6irvi38YWFd4 cgfZmbJs9Pm7/xTPZRLe5dj3S3L3BXmcfUDx4bs89c9lfEzBCjKIC2rQMHR8y1knN7k1 n9W9uyTNFGgs6Rt4Z59saMbeT0VmyuJ8EgZ8HHnKRgS+SJ6qUqkzzObvE1zCp+mjQO+F 5N6A== 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=VE61gMKhpnWZvU6qcog2kgqC/TE+2QO5LS6iHCKhdqo=; b=KqTFf+PkSTVwC33ytnyMJnUClo2UXqpCO1zM2jwzcELtwRIZXSkVxyX8P+H80H4+xO axg2xxCYCzRlr398dDPhghGm/Gzsd/pnG8fI3t5rNiEvaCQkaA2kcWqqc4EhzmqWcAqY +DKjeXt2kYy43gdCIJlDWhRFmaOH0gYHdpuuDZNoJG3gJ8Pe9GiCgNKWT3cImCz2KYwx RSsOuqxSpK+Z6CBd48PMazFbjhhwmdPFcvHId7J1Tz59cduEKr1Ypk6+wQfcw+eF61oK 9TnTOFjtH6Y77JW4MSRVZM60WgEB4tAmajUEdxTr4a/YufoWjjoeY2xMfaNrmRwLcp/y OnHA== X-Gm-Message-State: AOAM530CrJXFANpMWAxpBAmu3E0+geBPnbd5A1kIQUqsAG6UVwpI4Q9r igUHK9dxhvMxcnyUVKU5cW/xIw== X-Google-Smtp-Source: ABdhPJy/UG+ITMyG2/Mn4Uwf8UspkeO6+lrYf7WWF5pbE5NdbTB0zBoFHkgaWyjBjeOtQvNFfxzAEw== X-Received: by 2002:a05:6e02:1945:: with SMTP id x5mr2005197ilu.288.1641505277173; Thu, 06 Jan 2022 13:41:17 -0800 (PST) Received: from google.com ([2620:15c:183:200:2e0a:5e5e:fac:e07b]) by smtp.gmail.com with ESMTPSA id r1sm1688447ilo.38.2022.01.06.13.41.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 13:41:16 -0800 (PST) Date: Thu, 6 Jan 2022 14:41:12 -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: Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=X5251x9g; spf=pass (imf24.hostedemail.com: domain of yuzhao@google.com designates 209.85.166.180 as permitted sender) smtp.mailfrom=yuzhao@google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Queue-Id: 439DD180007 X-Stat-Signature: 8qn779a1puwkeas5cnj8q1odpuu55di3 X-Rspamd-Server: rspam04 X-HE-Tag: 1641505269-94349 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 06, 2022 at 05:12:16PM +0100, Michal Hocko wrote: > On Tue 04-01-22 13:22:25, Yu Zhao wrote: > > +static struct lru_gen_mm_walk *alloc_mm_walk(void) > > +{ > > + if (!current->reclaim_state || !current->reclaim_state->mm_walk) > > + return kvzalloc(sizeof(struct lru_gen_mm_walk), GFP_KERNEL); > > + > > + return current->reclaim_state->mm_walk; > > +} > > + > > +static void free_mm_walk(struct lru_gen_mm_walk *walk) > > +{ > > + if (!current->reclaim_state || !current->reclaim_state->mm_walk) > > + kvfree(walk); > > +} > > Do I get it right that you are allocating from the reclaim context? What > prevents this to completely deplete the memory as the reclaim context is > PF_MEMALLOC? Yes, and in general the same reason zram/zswap/etc. allocate memory in the reclaim context: to make more free memory. In this case, lru_gen_mm_walk is small (160 bytes); it's per direct reclaimer; and direct reclaimers rarely come here, i.e., only when kswapd can't keep up in terms of the aging, which is similar to the condition where the inactive list is empty for the active/inactive lru.