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 X-Spam-Level: X-Spam-Status: No, score=-8.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59700C43331 for ; Tue, 12 Nov 2019 19:13:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 103C8214E0 for ; Tue, 12 Nov 2019 19:13:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="oX0opbp+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 103C8214E0 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9FE5A6B0003; Tue, 12 Nov 2019 14:13:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9B03B6B0005; Tue, 12 Nov 2019 14:13:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8C5CA6B0006; Tue, 12 Nov 2019 14:13:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0118.hostedemail.com [216.40.44.118]) by kanga.kvack.org (Postfix) with ESMTP id 767F76B0003 for ; Tue, 12 Nov 2019 14:13:23 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 4BD284DC3 for ; Tue, 12 Nov 2019 19:13:23 +0000 (UTC) X-FDA: 76148573886.07.jelly65_6977a570c1b X-HE-Tag: jelly65_6977a570c1b X-Filterd-Recvd-Size: 6976 Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Tue, 12 Nov 2019 19:13:22 +0000 (UTC) Received: by mail-wr1-f66.google.com with SMTP id p4so19783708wrm.8 for ; Tue, 12 Nov 2019 11:13:22 -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=RtM0xm6pvdP2cIipj503CLA+c94Cc19gSxiP/7lkCo0=; b=oX0opbp+DaCHjx5NPFMutLUzOXNzS9qzrTQmMpDfKyHpUE5q/PBcpbwYBiWRikr0T+ ID/+T5BH/Fixjg/Un5sKJ2fqggO2bDcV/7OnEGuNU0SpT04cpVg5galbiZtTukCxNJYS ezBGYSpp20/SEYfh3UyfDeDfIEkrIYBCcXW+aZleBlQRN5OyfkqbdqDFnsp5UtYSR9mf MSbaVZpN3HHZAQ7cWAIzDpJh0W73RsMgFsDs7RfoYIRtLAR2dETepgjpOtotx15onznZ 92EEUVSNj0Cyic50ZTBFs243Xq2zt6jKDWsj2fFkzzD7kdi4QsUYfwQ9+hWVTT4odJd5 dnoQ== 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=RtM0xm6pvdP2cIipj503CLA+c94Cc19gSxiP/7lkCo0=; b=eNOLCV+8p+TxHqcnOqj7XHvBQFMDAvOPC6FzSkGGvM12vUTdNP8xeYIDt/H912O8O7 NIFOXhnLVyWmctSr7xW+EUoLNTc4BrkftoGhaBzSO50Y18taoGarkpdiVG46x8DiLARA HOloVu9kme/2anjn6pRsFDbjliHEqCVE/r7fUqObmm8OaBHO3yh9UshhhzwgXO22p/Qt VG83r7ESZ/GPz/mte0EiCxN9l7Wc4YM9u1/aDRKSMnUtKAiZ8T4e4igUfuGWexCQhz7E 2Z2L4jPTIB810mvjBar1CfMZ0TxV9q8oxpFxvf9FPPTxEC0Z3mX2TDFdmYXonJmHdXVY w7Ng== X-Gm-Message-State: APjAAAXM8oRTE0FQPROz+l6bI1tQ1+4Bou0osWwduJhOYaosCLk5/mcK lFvi4WmO+G2kO2a/N6/j/WjXbbyT1lVuy0bMUPYEYg== X-Google-Smtp-Source: APXvYqzMdkx5IZeFl9kZ1JAz2Fz3PH7Ac1ewNQNH9EP7dZAMdZyI4Vlcv9hr2OgkmnZtO+bPOV89e1xK6L7Mpft+sdo= X-Received: by 2002:adf:d18b:: with SMTP id v11mr28764776wrc.308.1573586000825; Tue, 12 Nov 2019 11:13:20 -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: <20191112180019.GB178331@cmpxchg.org> From: Suren Baghdasaryan Date: Tue, 12 Nov 2019 11:13:09 -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" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000003, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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); ?