Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2583366pxp; Tue, 22 Mar 2022 01:25:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9p+hWSIbfVg52KAEJt/maSkxWikjdZdtXNMu5KaAJi3BrRoUDm1fHiwzftzPAQ4JrCK3E X-Received: by 2002:a17:907:2053:b0:6e0:2ad8:e10e with SMTP id pg19-20020a170907205300b006e02ad8e10emr5588836ejb.167.1647937545522; Tue, 22 Mar 2022 01:25:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647937545; cv=none; d=google.com; s=arc-20160816; b=0lU78VwTpfPXfro8ygs8v6F9OScXgglIaT5qIoHe0KYlhR8YaTVke4VBN9+578d72F Q4rpz7VlkeNtmWrMhZEw7xpPFBFdUhgsLw/wdwNUltxiEhXunYYQ46wohsChn1CCtxiV 4pNkHwswJniSuhVX02ml1miusPU9bcpPMPoSS0VSLfx6VBLT0kh0PVh4TBYTroUqh6hZ afoSgVhYgh25p+U5ctA/WKcTIEdvi3y03D5sXsGZ54WilbfR+QOZ8/xpLbsGoFfM2Jm+ jy3pr+YKQpgUNUzsAclYhdaqLquVWTsMlnGVARl8kmbdoZ+/nbertXE/g1dj8+B6vmgW H3Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ejYqrEpcN+YIapqTaek6UuldGWcXdxvGA3dM/VeJRBw=; b=An5dI6hmftu+FVjUjrPt/bby9Cll4wCAQObzkJn8AGTu1oESR63LKivFLm5pH5cFfp UUfYQtOCAqa00Kpur6KumYXLRrApVT2rSNJY47ljJ1gyh8haCzjhxdgS0OUTjt8vVsca /vwViz2wK3ul78XU20irItwKCVe9KFn4gwSDWAEgAuH7NuSeS6dqeK2QRcHGt2gTzozD i1W+4inq28ysJyssiv2Si3jmshgN2AZaSq8Gv+cvlAxhgm6qyqvwTm6rxJHFUaK2huSm 1UIq75/R2ZYHEJg06ERdaVjcr/qoH9de7t3eCUdGvI4JZFVORq1yaNJqx6A6xyFaH+3t rpmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=BUFmL4he; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u10-20020a50d50a000000b004194b1618f9si2926160edi.62.2022.03.22.01.25.15; Tue, 22 Mar 2022 01:25:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=BUFmL4he; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230238AbiCVIPp (ORCPT + 99 others); Tue, 22 Mar 2022 04:15:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229718AbiCVIPo (ORCPT ); Tue, 22 Mar 2022 04:15:44 -0400 Received: from mail-vs1-xe2b.google.com (mail-vs1-xe2b.google.com [IPv6:2607:f8b0:4864:20::e2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B68833A13 for ; Tue, 22 Mar 2022 01:14:17 -0700 (PDT) Received: by mail-vs1-xe2b.google.com with SMTP id 2so10265213vse.4 for ; Tue, 22 Mar 2022 01:14:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ejYqrEpcN+YIapqTaek6UuldGWcXdxvGA3dM/VeJRBw=; b=BUFmL4heEnQlaoWLUylgiBVgyrJVVkojiCMeAXJFkN+klvf/L4GwYq1ryCISPtRUGS si+JBR7yCvBp7J4j0vIyULINRl51j4D2xaSkm1tVlpAqr9ogkF+C20iqQWzgRJKDf6xi 1M1mqaHI6o7a5+6Yz7jK1F1rJL5JiJwjft7xaB1CBGWFhb62E9R6oyLDzXkkzC3kDjcn ZRn5V0IZBgmPnaC5K5gxyqsWjQoKO32xo7oY4B415L1eK0tIF9nzSwNhbzEasO4BBShX VTjugLCAiW2YsPV+ybWh1e1Uw+wun1LOiGG/FxAAD80r/3EsiSoGEhgcnIbXMnNCJNGK M2eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ejYqrEpcN+YIapqTaek6UuldGWcXdxvGA3dM/VeJRBw=; b=R8CmRJpVsPDkgP327aYi/JqbCBZqjP4Tp2dlVmswHrN3PwhEn9fDXQkyXXK9rpyYu0 rfJP9eASxMx1Lk0M/pFnxjsY4bdJoPcAZmda7eJdUZvilJDOKXdP6vLAXSLQceQU0i/q UyY0lBYylt9/iesCeprXX7/dSRRlCGDRXy/XJRkRSnr2hVUR1lnQN5BMAhoKaxKvlWbs HTpfdJZQ7sgHUDTkiSg6BeCiwGHQkUb1QoXG7eSph1Qp8+AU4bquNLl0aFBh9+IjhTCF 4Xejg+2K1VCotvKwYidqjxuh4uRcT8GqYVkSxv1TIWUJ8G1gthwYQ3LYsID+5v1Vf8hn HMsw== X-Gm-Message-State: AOAM533Ehm19ErIHCLaqxtN52aeSI87jomSF9ZgYnClg5rCFnvmflQ/h 10nZdjn021YzPk1kW+h+U8J8JYOFeRoeNoCgCnvXqA== X-Received: by 2002:a67:f956:0:b0:324:eb38:52fb with SMTP id u22-20020a67f956000000b00324eb3852fbmr5339929vsq.22.1647936855962; Tue, 22 Mar 2022 01:14:15 -0700 (PDT) MIME-Version: 1.0 References: <20220309021230.721028-1-yuzhao@google.com> <20220309021230.721028-12-yuzhao@google.com> In-Reply-To: From: Yu Zhao Date: Tue, 22 Mar 2022 02:14:04 -0600 Message-ID: Subject: Re: [PATCH v9 11/14] mm: multi-gen LRU: thrashing prevention To: Barry Song <21cnbao@gmail.com> Cc: Andrew Morton , Linus Torvalds , Andi Kleen , Aneesh Kumar , Catalin Marinas , Dave Hansen , Hillf Danton , Jens Axboe , Jesse Barnes , Johannes Weiner , Jonathan Corbet , Matthew Wilcox , Mel Gorman , Michael Larabel , Michal Hocko , Mike Rapoport , Rik van Riel , Vlastimil Babka , Will Deacon , Ying Huang , LAK , Linux Doc Mailing List , LKML , Linux-MM , Kernel Page Reclaim v2 , x86 , Brian Geffon , Jan Alexander Steffens , Oleksandr Natalenko , Steven Barrett , Suleiman Souhlal , Daniel Byrne , Donald Carr , =?UTF-8?Q?Holger_Hoffst=C3=A4tte?= , Konstantin Kharlamov , Shuang Zhai , Sofia Trinh , Vaibhav Jain Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 22, 2022 at 1:23 AM Barry Song <21cnbao@gmail.com> wrote: > > On Wed, Mar 9, 2022 at 3:48 PM Yu Zhao wrote: > > > > Add /sys/kernel/mm/lru_gen/min_ttl_ms for thrashing prevention, as > > requested by many desktop users [1]. > > > > When set to value N, it prevents the working set of N milliseconds > > from getting evicted. The OOM killer is triggered if this working set > > cannot be kept in memory. Based on the average human detectable lag > > (~100ms), N=1000 usually eliminates intolerable lags due to thrashing. > > Larger values like N=3000 make lags less noticeable at the risk of > > premature OOM kills. > > > > Compared with the size-based approach, e.g., [2], this time-based > > approach has the following advantages: > > 1. It is easier to configure because it is agnostic to applications > > and memory sizes. > > 2. It is more reliable because it is directly wired to the OOM killer. > > > > how are userspace oom daemons like android lmkd, systemd-oomd supposed > to work with this time-based oom killer? > only one of min_ttl_ms and userspace daemon should be enabled? or both > should be enabled at the same time? Generally we just need one. lmkd and oomd are more flexible but 1) they need customizations 2) not all distros have them 3) they might be stuck in direct reclaim as well. The last remark is not just a theoretical problem: a) we had many servers under extremely heavy (global) memory pressure, that 200+ direct reclaimers on each CPU competed for resources and userspace livelocked for 2 hours. Eventually hardware watchdogs kicked in. b) on Chromebooks we have something similar to lmkd, and we still frequently observe crashes due to heavy memory pressure, meaning some Chrome tabs were stuck in direct reclaim for 120 seconds (hung_task_timeout_secs=120).