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 5E153C433EF for ; Tue, 11 Jan 2022 23:17:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DF5C66B00F2; Tue, 11 Jan 2022 18:17:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DA5416B00F3; Tue, 11 Jan 2022 18:17:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C6D166B00F4; Tue, 11 Jan 2022 18:17:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0082.hostedemail.com [216.40.44.82]) by kanga.kvack.org (Postfix) with ESMTP id B98BE6B00F2 for ; Tue, 11 Jan 2022 18:17:03 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 78BCD8D8EC for ; Tue, 11 Jan 2022 23:17:03 +0000 (UTC) X-FDA: 79019568726.21.0A3BF3B Received: from mail-io1-f53.google.com (mail-io1-f53.google.com [209.85.166.53]) by imf12.hostedemail.com (Postfix) with ESMTP id 2A64140009 for ; Tue, 11 Jan 2022 23:17:02 +0000 (UTC) Received: by mail-io1-f53.google.com with SMTP id w22so1115951iov.3 for ; Tue, 11 Jan 2022 15:17:02 -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=+BNyhiKbMm4RyIg8JNrtqDxZgbHGdo0J7XNrf0piRew=; b=iskzbXe5xMvIxCUIg2oP1wUuouDfhgLnCC+sQJPAAAZEHx/x1j5Al9PEfKyyAXPPL0 8cv4uckuhLYcffGBt04dCVj17g9Bx9b3LLN4XH14iZtpWuxjHsDC+6fM5paFu0GZ7ZOc OPSe0TwDLDOQBnMk5VrrS2x7TJvIhgv9+SOESCKNl0sM50g+kb8sjRU9VXmsCgSlB7Pk Sq0yuZLlWA/XbIf4jLqEv9rrIPGbRiXCNb/WHEkTua98LZ7UGm7jeNIauz9xcODpbM38 ONSBKKdQR8MmmejnouArJBl/1Vl4tiNj2Lkr5VwJyJE0IoBNbgSbtK2hLXLSf3//qmTk nv1g== 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=+BNyhiKbMm4RyIg8JNrtqDxZgbHGdo0J7XNrf0piRew=; b=3J9ipUc/JTlk3RO7ARtX3avfPwUP0hplsi/BA2vWscCBmGEX7oEBk4vmOmM/LHJ46P mk4V0Pwnk3kolYIt5q1x7zWnvS4N+oDhEGkzfGKcRJzSuVPu7TV3Wehk+S3i2DY4KNni VaozLHef5DTTBb5/1tiWgTyEIbA+vu9IJq+Rpp8QMUfb3fi9nqYbBRw2Em+cIyTjrFta B38xVlqTn5Vpphu6ICH5dxuIRZ79lVTsjPGSOV8mjEJz7k7M/w+Wjihu0iUwF2zaKz3S Zkveumo6mqupvtiCD4Lz+wvU6DwoNAm8sR5gYP3New2ZjAnW/qW+EglOp85oYIJuV3B0 gslQ== X-Gm-Message-State: AOAM532+/+NZcb0j2PDmEn3qoFbSGs2eywAEb9wNCxCbQVEXxgQK/V7A +pIHxApxgpXCWnusaaR3DOsPzA== X-Google-Smtp-Source: ABdhPJyF9jePSeHs9NHaVjjmJYEtoTSK60Y5oIKEaaIgZtxgs/ZSrSvwH+4hyESidsEw5kW2XjQauQ== X-Received: by 2002:a02:aa10:: with SMTP id r16mr3590702jam.36.1641943021690; Tue, 11 Jan 2022 15:17:01 -0800 (PST) Received: from google.com ([2620:15c:183:200:b6b6:70f4:b540:6383]) by smtp.gmail.com with ESMTPSA id o12sm6722264ilu.86.2022.01.11.15.17.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jan 2022 15:17:01 -0800 (PST) Date: Tue, 11 Jan 2022 16:16:57 -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: 2A64140009 X-Stat-Signature: tfbg8ona6x5h9disn46stguxjdqycp57 Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=iskzbXe5; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf12.hostedemail.com: domain of yuzhao@google.com designates 209.85.166.53 as permitted sender) smtp.mailfrom=yuzhao@google.com X-Rspamd-Server: rspam02 X-HE-Tag: 1641943022-928867 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 Mon, Jan 10, 2022 at 04:01:13PM +0100, Michal Hocko wrote: > On Thu 06-01-22 17:12:18, 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); > > One thing I have overlooked completely. I appreciate your attention to details but GFP_KERNEL is legit in the reclaim path. It's been used many years in our production, e.g., page reclaim swap_writepage() frontswap_store() zswap_frontswap_store() zswap_entry_cache_alloc(GFP_KERNEL) (And I always test my changes with lockdep, kasan, DEBUG_VM, etc., no warnings ever seen from using GFP_KERNEL in the reclaim path.) > You cannot really use GFP_KERNEL > allocation here because the reclaim context can be constrained (e.g. > GFP_NOFS). This allocation will not do any reclaim as it is PF_MEMALLOC > but I suspect that the lockdep will complain anyway. > > Also kvmalloc is not really great here. a) vmalloc path is never > executed for small objects and b) we do not really want to make a > dependency between vmalloc and the reclaim (by vmalloc -> reclaim -> > vmalloc). > > Even if we rule out vmalloc and look at kmalloc alone. Is this really > safe? I do not see any recursion prevention in the SL.B code. Maybe this > just happens to work but the dependency should be really documented so > that future SL.B changes won't break the whole scheme. Affirmative, as Vlastimil has clarified. Thanks!