Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1004133ybc; Tue, 12 Nov 2019 12:36:56 -0800 (PST) X-Google-Smtp-Source: APXvYqxYU1X/2pxOSaHQsbWK9FF2M7Gtj0cvrMIUTyXSskjVXpeY2g2Aag0gs292/v+LMRv6nmrO X-Received: by 2002:a17:906:a38d:: with SMTP id k13mr30116819ejz.213.1573591016407; Tue, 12 Nov 2019 12:36:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573591016; cv=none; d=google.com; s=arc-20160816; b=r7VclV6P4NeVoUsIzMdJmQW8cZgqJVjS4h7JSNIHyIDEUZp3iPSe6dcci+k/UUKJgt V9MJQFTxMgazL1R3pnXwcCiQrOwTV5Z1LzDe0abdTvh4gc8qJsEly2E+wFUAiKuphjhO j65xzmOUJ/5KywrCChqS5gG+H9vvKIp3YUn/hHFIQ6s+sLwVP9fCQWBhfXSKukICuCsv isaKgc3HDtNaiKy1ZDEjnSUlNZ9m9XZEP4wE/6BvNr6wBHvFfAlWd0XyVywYnIRxRyE4 01gaSM793xSFjYrKp5TGcC1HpGsI24IlrXcmL4145ceXHg/Icy7oSN70H9LIj4lb165Z K/ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=w2HWZCYTuyG/iiIWgucV3SL/wKiXCiXBU5oRVlG/JoY=; b=fbSKm7EDY2ldntvYA+/XijmudBZGMZ2GJ0AC0Fc6uH995CTQFXRM4eq9ya7uNROo0L tG7ApykQLTvAlp+LZZBTRkunw+qLabmWRtDEdInzD34OVw7zdbht/ABFU0W614nicYR1 jBiwai+81NrnWBBYn36r8G5l9IMhuw0uJsfM/3dSSZAozHEBgJWDCIYZD5bcV8R5fJVg 87EcW6YKe2gQEUQ/wNpA19LKSgcFQ/bklQtULIGHUMeeXJti2DL/Kkznkm3w3fOWFsAD ovo6VxLowCqkHLcK1qqn/OqYnWxc/ICZuXIamy9Y3Xb5PO1h0a6A+rwUj3ioHnoD7aHJ QmZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=nIfBYYpx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i13si719526ejc.76.2019.11.12.12.36.31; Tue, 12 Nov 2019 12:36:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=nIfBYYpx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1726988AbfKLUeR (ORCPT + 99 others); Tue, 12 Nov 2019 15:34:17 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:32981 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726659AbfKLUeR (ORCPT ); Tue, 12 Nov 2019 15:34:17 -0500 Received: by mail-wm1-f66.google.com with SMTP id a17so3219452wmb.0 for ; Tue, 12 Nov 2019 12:34:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=w2HWZCYTuyG/iiIWgucV3SL/wKiXCiXBU5oRVlG/JoY=; b=nIfBYYpx2BPy8Ny2KgYnvusMIUoId7JvzJVuq3x4uT3Ce5l33QonIgnPodqpzgfLnk KwUjAuYZyyC504ndkw8KH/zz1rB8QWChYirmO4TSeQRJ6uW970ne8kuJ64kiTf0mP6tZ 9ZZS1D4Xr29niL4OXMBJhIWVbzrtBr4f5Gfee8T9zAZSGa+P8TpFWxnmeZbIMKgJCZ30 +1tG1fXzk837jA0obwmLORJ95JlTbdlhD4AAy0UG/RNvvw71D1IifjG6atHbmC0HWnxf bjCtQ/mXtEzj3NNFH/q/nufeqZqdwQMDoM+7iXWW0rH2UrGK1DgF9QP5YIrOobEwuu7e uzuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=w2HWZCYTuyG/iiIWgucV3SL/wKiXCiXBU5oRVlG/JoY=; b=Jm49P93VYWi5aSZ4rDyCMjC7S2vT1sT8AqqVMZnzXJwMVzK2znYDGf5gV2dAiWqxSS XLdmrt5y2FdLoMPIlAWybsqcvgTMrSkwz7cdKigHZ+FlAVbCxZzLWWNF3oXVagsvRe4w lKm6Yco06Gk2wics72n1etq9b/qrFTN3OG3W1N0YbNyw4qK3MpoH+bUqS5mC8CUzqR2I +PcrHWvLG+efGDKDibZJu7o7ywKE9SXnFrNOQ9lCX8gXdita3zdr6nz46OjfH/cM7UF6 pgjnx7oAIEklNEG+M8RyZStwB299gXtpVUsD0A20w5nefNuu1QQXHoGaP3bICR1d+NQk j0Rw== X-Gm-Message-State: APjAAAWUJMqDfHBxpWyuiqhiru5yflMErAm6iH7eZUcjZD64KKIFNIrG GRuKbVY28G6Ggs3gFPls/A1r/GpArLdt1VAj+7zkpQ== X-Received: by 2002:a1c:8055:: with SMTP id b82mr5959862wmd.176.1573590854911; Tue, 12 Nov 2019 12:34:14 -0800 (PST) MIME-Version: 1.0 References: <20191107205334.158354-1-hannes@cmpxchg.org> <20191107205334.158354-4-hannes@cmpxchg.org> <20191112180019.GB178331@cmpxchg.org> In-Reply-To: From: Suren Baghdasaryan Date: Tue, 12 Nov 2019 12:34:03 -0800 Message-ID: Subject: Re: [PATCH 3/3] mm: vmscan: enforce inactive:active ratio at the reclaim root To: Johannes Weiner Cc: Andrew Morton , Andrey Ryabinin , Shakeel Butt , Rik van Riel , Michal Hocko , linux-mm , cgroups mailinglist , LKML , kernel-team@fb.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 12, 2019 at 11:13 AM Suren Baghdasaryan wrote: > > On Tue, Nov 12, 2019 at 10:00 AM Johannes Weiner wrote: > > > > On Sun, Nov 10, 2019 at 06:15:50PM -0800, Suren Baghdasaryan wrote: > > > On Thu, Nov 7, 2019 at 12:53 PM Johannes Weiner wrote: > > > > @@ -2758,7 +2775,17 @@ static bool shrink_node(pg_data_t *pgdat, struct scan_control *sc) > > > > total_high_wmark += high_wmark_pages(zone); > > > > } > > > > > > > > - sc->file_is_tiny = file + free <= total_high_wmark; > > > > + /* > > > > + * Consider anon: if that's low too, this isn't a > > > > + * runaway file reclaim problem, but rather just > > > > + * extreme pressure. Reclaim as per usual then. > > > > + */ > > > > + anon = node_page_state(pgdat, NR_INACTIVE_ANON); > > > > + > > > > + sc->file_is_tiny = > > > > + file + free <= total_high_wmark && > > > > + !(sc->may_deactivate & DEACTIVATE_ANON) && > > > > + anon >> sc->priority; > > > > > > The name of file_is_tiny flag seems to not correspond with its actual > > > semantics anymore. Maybe rename it into "skip_file"? > > > > I'm not a fan of file_is_tiny, but I also don't like skip_file. IMO > > it's better to have it describe a situation instead of an action, in > > case we later want to take additional action for that situation. > > > > Any other ideas? ;) > > All other ideas still yield verbs (like sc->prefer_anon). Maybe then > add some comment at the file_is_tiny declaration that it represents > not only the fact that the file LRU is too small to reclaim but also > that there are easily reclaimable anon pages? > > > > > > I'm confused about why !(sc->may_deactivate & DEACTIVATE_ANON) should > > > be a prerequisite for skipping file LRU reclaim. IIUC this means we > > > will skip reclaiming from file LRU only when anonymous page > > > deactivation is not allowed. Could you please add a comment explaining > > > this? > > > > The comment above this check tries to explain it: the definition of > > file being "tiny" is dependent on the availability of anon. It's a > > relative comparison. > > > > If file only has a few pages, and anon is easily reclaimable (does not > > require deactivation to reclaim pages), then file is "tiny" and we > > should go after the more plentiful anon pages. > > Your above explanation is much clearer to me than the one in the comment :) > > > > > If anon is under duress, too, this preference doesn't make sense and > > we should just reclaim both lists equally, as per usual. > > > > Note that I'm not introducing this constraint, I'm just changing how > > it's implemented. From the patch: > > > > > > /* > > > > * If the system is almost out of file pages, force-scan anon. > > > > - * But only if there are enough inactive anonymous pages on > > > > - * the LRU. Otherwise, the small LRU gets thrashed. > > > > */ > > > > - if (sc->file_is_tiny && > > > > - !inactive_list_is_low(lruvec, false, sc, false) && > > > > - lruvec_lru_size(lruvec, LRU_INACTIVE_ANON, > > > > - sc->reclaim_idx) >> sc->priority) { > > > > + if (sc->file_is_tiny) { > > > > scan_balance = SCAN_ANON; > > > > goto out; > > > > } > > > > So it's always been checking whether reclaim would deactivate anon, > > and whether inactive_anon has sufficient pages for this priority. > > I didn't realize !inactive_list_is_low(lruvec, false, sc, false) is > effectively the same as !(sc->may_deactivate & DEACTIVATE_ANON) but > after re-reading the patch that makes sense... Except when > force_deactivate==true, in which case shouldn't you consider > NR_ACTIVE_ANON as easily reclaimable too? IOW should it be smth like > this: > > anon = node_page_state(pgdat, NR_INACTIVE_ANON) + > (sc->force_deactivate ? node_page_state(pgdat, NR_ACTIVE_ANON) : 0); > > ? On second thought that proposal would not be correct since deactivation is not the same as reclaim... So the way it is now looks correct. Reviewed-by: Suren Baghdasaryan