Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp919527ybc; Tue, 12 Nov 2019 11:14:57 -0800 (PST) X-Google-Smtp-Source: APXvYqwJLAXpeOxlanOw0F+udTTmwHXHAeSHXvfFxOvwob61+X6hLlqtSVEsv+AFuQ4lHkAurGRH X-Received: by 2002:a17:906:70ca:: with SMTP id g10mr27267654ejk.141.1573586097353; Tue, 12 Nov 2019 11:14:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573586097; cv=none; d=google.com; s=arc-20160816; b=lvaXCggo4k/R8tJTX+pH247PP4SDsGXDze7j54LaQ/sZEchWgUWHWSYskK8pJ+APho TkO90njYHxMANqG2ei6wO8EQg6x85wenchnWkdpaW6CbgKawKSMV+Ma+xzsm2HGygSzN WS1aULo0z2O9tei66FfazgNV5cfFXdTAc44VAxCdK7MiWsR9kyVgGvuxPRe77DkNklAa GgYPxlqYs6PCELCtvmTF+TTJ5gdPMbF14IUHmFi3Z3weqIVuq/N+mjEvJRe1rKbMRmju T8EtvnNaVZqCk2e23LDvnIfNtewWBNPnpZSMCv9uqhgi490Nf59akg/hNPODW9Y43n8z kHyQ== 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=RtM0xm6pvdP2cIipj503CLA+c94Cc19gSxiP/7lkCo0=; b=tnc2ew5dbmgyFpTTzZBz8tXYn6f/j4of22SZweBRZAT+Hdu06ONXYz/AiP1KdiAFzp luF6rLnsnAS75yEKKEJ7ggP/9s58zOrCUb9DiCx1xRE5g6jATQh0Kpa5iqIr12loZYJr e8Hn/ZVzoLI80Z3uwrIkQnWS99gNahl6YbwyJOhas4KYbPoiGhdPttY6CHg4O7X9fd3X ex9OU+FVSIunnItveNLYVr3d4Fuf/vSQD/R8B5UnBkkHpx6NtA8mUFoewsVwo7C8hySb b2AQv1vIaIc5fcqgtSnceT8pV9epEPaGT6BxmCyeU9mfKS472Z84NWKexIomx9E8G4ID IKOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=oX0opbp+; 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 c1si13511885eds.170.2019.11.12.11.14.33; Tue, 12 Nov 2019 11:14:57 -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=oX0opbp+; 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 S1727153AbfKLTNX (ORCPT + 99 others); Tue, 12 Nov 2019 14:13:23 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:42807 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727119AbfKLTNX (ORCPT ); Tue, 12 Nov 2019 14:13:23 -0500 Received: by mail-wr1-f66.google.com with SMTP id a15so19771680wrf.9 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=TlyTaFEgeKLXuNIjCIFGzkBRJyYJx6zg4y7mKZST3V55swmghSoXhwafBf1MKy3Ost ioVNwDePh2cd7gVdoNotrDhgC7ST/vsvoRHsUyKJ+9ueUwEwY0djDwYj/v27eiW1PQYX NacgFLi1AHD/iNbeF5swhAtNg1m+ItCOl0nnyaB3Fz138m7A9Pi8t521DbVyF9FPDDCm FZWq8SwvauN48txm7zhb3o3OKRRitZd32F1m1X1dqf09wY5KNt2TOxoA34/r0jtlrEbS ZwDAy7AQXsvRKKJNDAI7iy3OMcUc9qTbomeZW+wTcOWrBwKhJMOotIRiesV14t5Zu7wv JgdA== X-Gm-Message-State: APjAAAWRDKnVI1VXCjs04TWoph54nABfLt9cY4rrEfTSQ/hLhgPHcFoT tVQ2nTBkzDSGLWt2Sf5xl12wVG/G/VhvUxbLUn0sSw== 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" 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 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); ?