From patchwork Wed Feb 14 06:05:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinsey Ho X-Patchwork-Id: 200815 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp1014884dyb; Tue, 13 Feb 2024 22:07:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUHp8V/biR8kfTyfix6yyOp/EsI4LHnzkv+kodWr9MSSGvXYD3F6615eRTDIriUKfPbEP3lGF8koo1NxiDyfKSgmv9t5A== X-Google-Smtp-Source: AGHT+IH8E+aqQ8QcYkaM8DzhWyPV4P0S8WdER7q9pqE7a23emFswzqJ47dnjn5REKLeGMnTumuER X-Received: by 2002:aa7:c541:0:b0:562:1a77:19a7 with SMTP id s1-20020aa7c541000000b005621a7719a7mr855150edr.11.1707890851031; Tue, 13 Feb 2024 22:07:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707890851; cv=pass; d=google.com; s=arc-20160816; b=M8YrLTzTQzutDt8k0SIJaMk7rda/answkUtJL/LRfbjCN7hAkiyOcEcJQFSyaDzG6c 88TanldGZ53j2bOy15pv3HexYW2LGOXFUZQtJc9+PxHoNabF/hKbXD4yUHANWM33a6D2 n0oggbFSUqrjLgH4uZUL5uDRBKZov7szWRI3bzXmdYDVJ31NKA7V1L2bt3Vm7DbSFLKG MKQyheIqNkaN/QEuu4si+24H4ijdqrbY5+9/HOPaMgaHx4Rj1Z3lXol8Upq+TZdWoZL2 8CQ76XXt9hBaWoHhYCW8HDDrcvKttoAKduAELdvRaeCYVh0NetzZLRBKzEIgmsvTKFdy B76g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=PA0Wvzy3nOg04HsvD1HxZoLNsuEGHVAo5nrJURoHvxc=; fh=8O5RabfpiVksizK3eckx5Un926UppoHvdUCYVQ6fFc0=; b=TRigoneIL3Sg4Vuc9/LCc1NKYIv2YsN4Np0O0E7KUUn/KuMTxjxTMpXCaIW3ewpitB FBPSdDv/wIhc6UqFPrxRZHSR8SH6agRQ1FyllWh5ZY0qTahGBWkqtfvQwIfv0efabeIW JFzLZW9eyofaeVZEL/HibXgZbs7pBF6/LnfuiKUkfITWJew93+RkTuPY2w75yg0AJDQb ewj84aVqyiegZZhu4arYIywBlnaMLZn/m2ys+zPqMjW8YWck6+1UkHo0omHswOwrl9Ro NW9vXN4GeuenhvEESFZ5wS6sza+V6eGknBcSMCQNIt+ZUqT5pFHFhunyGsS0HhHHUTaT 20BA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="feM/altA"; arc=pass (i=1 spf=pass spfdomain=flex--kinseyho.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-64767-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64767-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCXWoURzkk9n4kkH+UhqvEqNRbOJnp6xTIU0z0TCVW0hJojbim2kA1SIlFkL3B4KSGSM/iXKJqLHB45qvSRhy63xwE+2yw== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id y19-20020a056402135300b0056022a0d6e5si4515529edw.466.2024.02.13.22.07.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 22:07:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64767-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="feM/altA"; arc=pass (i=1 spf=pass spfdomain=flex--kinseyho.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-64767-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64767-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A36501F285AE for ; Wed, 14 Feb 2024 06:06:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0205A11CAD; Wed, 14 Feb 2024 06:06:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="feM/altA" Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EDE7F11184 for ; Wed, 14 Feb 2024 06:05:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707890761; cv=none; b=iaVcNiNMyxxKMnc2INzz/t1/i0Pujakd530Du32eivXX6ozm0j4T3dAqiE8dXW8T1O7oMxGGPP5mjoVGpvXBPFVEV1G3eNlEtCDMijmruO7H9ASwG1IGTzB0LB3YZrbcBNWjX977PMhjh1wJvsTfop97TiTdP+enurisLOG/Oyk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707890761; c=relaxed/simple; bh=iEbHcbHJ+9bB3Sa9kRTJ4KWMBUFabcdRFDkuVsMtWKQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=FWRaw1xTYE/KsyNB202Y/O7MM9BKJVbHUwjNGbDnZlWJ/x6I8hhv6fkylw7j/vsyT64F6EadT2TzxCe8FvodnizAPZzdr8cRdHa5tejQLKYjIkd+jCv0jnhM1MnNYaN7kJWEN7QlQw/qbmzhSVpKW5DBiRXHwpUzG8itpv8KiEs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--kinseyho.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=feM/altA; arc=none smtp.client-ip=209.85.214.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--kinseyho.bounces.google.com Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-1d409124358so51042715ad.1 for ; Tue, 13 Feb 2024 22:05:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707890759; x=1708495559; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=PA0Wvzy3nOg04HsvD1HxZoLNsuEGHVAo5nrJURoHvxc=; b=feM/altAcmvKtvSZnjX8wLBL9s8JtK9fcFijOJekIbUXl+nVoP46azKtCp4ZvnXxBJ fluPcugcHXuJQ1rG1b6dgSXD4haI1WBFPLO0aW9fqKeQcjV7i2tErzlAaH63b2sF5PNJ Z2JAN1IkIaB6knI4pSDDH/tlBHT01bUYBQDZl3u/vYE5JDzycSOqW3Erel0Rr/i1EVsP xcEsW+zIPeSS0xInjsAIr75p7LIDVdZ1yZRMzwHQ7O5C3v8C5A4W/leXA3QqaiV+69Uo APzaCzMwE0v6Dx3eeWE05M0rpKtTEsiZgNRy0dUEE8O7/Zu6CwSRLXzfwY12wAepGXUj RCNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707890759; x=1708495559; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=PA0Wvzy3nOg04HsvD1HxZoLNsuEGHVAo5nrJURoHvxc=; b=oN8FDCU35dE5vATIKKjKKKg9nZqJDjioYZJwGUhH2LW4dHMAaT27XbHtGWAfUtBERw xdPBwlrCoxArkYCH+FRTaWu3AcyWLei5mKV4wPLvTHNH2NhQKvd80HtWSjqWY7bH72XY 0nP3ERmqPjubiuiCwb+VKeK0e4xAW2/2/xvw4nexp+Ynumuu8JEqhSVMJVmHzSfS+C5y AhJl1Rb37Czu4Vk+lMwEAXGu8Dp+oJejniFYdkPRF2pPGeJwpUsxXvSrqGsGo4qBsye6 cZqTe/7ea/KI50PQXiav9GAt2EDy9OEfjL52wzdIKTo6/60rxDQxqGnlmEpsmSrR0O++ cQZw== X-Forwarded-Encrypted: i=1; AJvYcCVeDrJGPiQE+38JvyP9EHcusG2ohjQCY9GW4uHaKrLrRU9ODiEwtynPb3NNEg2g8rNeiXZMNTH8Q0rCL8g54l1+Bw7CrROJ7MvwMJH7 X-Gm-Message-State: AOJu0Yzzuiezu5KNKm3ontvMrMBUYnpxlV58tGEC22kvQlI/GcXp6QYo hqgsBm2iTkXi4Bbt9x6arGtgo3H1tgUBZBQR+dm9UlWw/g/dLgqn4l7xGHBI+PyQiGH/mfddESF fssu/EGMsqg== X-Received: from kinseyct.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:46b]) (user=kinseyho job=sendgmr) by 2002:a17:902:ea11:b0:1db:6187:61d7 with SMTP id s17-20020a170902ea1100b001db618761d7mr9768plg.13.1707890759283; Tue, 13 Feb 2024 22:05:59 -0800 (PST) Date: Wed, 14 Feb 2024 06:05:34 +0000 In-Reply-To: <20240214060538.3524462-1-kinseyho@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240214060538.3524462-1-kinseyho@google.com> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog Message-ID: <20240214060538.3524462-2-kinseyho@google.com> Subject: [PATCH mm-unstable v1 1/5] mm/mglru: drop unused parameter From: Kinsey Ho To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yu Zhao , Donet Tom , "Aneesh Kumar K . V" , Kinsey Ho X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790853357291071611 X-GMAIL-MSGID: 1790853357291071611 struct scan_control *sc is currently passed into try_to_inc_max_seq() and run_aging(). This parameter is not used. Drop the unused parameter struct scan_control *sc. No functional change. Signed-off-by: Kinsey Ho --- mm/vmscan.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 54cb7685beba..9d15648561ec 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -3834,7 +3834,7 @@ static bool inc_max_seq(struct lruvec *lruvec, unsigned long max_seq, } static bool try_to_inc_max_seq(struct lruvec *lruvec, unsigned long max_seq, - struct scan_control *sc, bool can_swap, bool force_scan) + bool can_swap, bool force_scan) { bool success; struct lru_gen_mm_walk *walk; @@ -4690,7 +4690,7 @@ static long get_nr_to_scan(struct lruvec *lruvec, struct scan_control *sc, bool return nr_to_scan; /* skip this lruvec as it's low on cold folios */ - return try_to_inc_max_seq(lruvec, max_seq, sc, can_swap, false) ? -1 : 0; + return try_to_inc_max_seq(lruvec, max_seq, can_swap, false) ? -1 : 0; } static bool should_abort_scan(struct lruvec *lruvec, struct scan_control *sc) @@ -5350,7 +5350,7 @@ static const struct seq_operations lru_gen_seq_ops = { .show = lru_gen_seq_show, }; -static int run_aging(struct lruvec *lruvec, unsigned long seq, struct scan_control *sc, +static int run_aging(struct lruvec *lruvec, unsigned long seq, bool can_swap, bool force_scan) { DEFINE_MAX_SEQ(lruvec); @@ -5365,7 +5365,7 @@ static int run_aging(struct lruvec *lruvec, unsigned long seq, struct scan_contr if (!force_scan && min_seq[!can_swap] + MAX_NR_GENS - 1 <= max_seq) return -ERANGE; - try_to_inc_max_seq(lruvec, max_seq, sc, can_swap, force_scan); + try_to_inc_max_seq(lruvec, max_seq, can_swap, force_scan); return 0; } @@ -5433,7 +5433,7 @@ static int run_cmd(char cmd, int memcg_id, int nid, unsigned long seq, switch (cmd) { case '+': - err = run_aging(lruvec, seq, sc, swappiness, opt); + err = run_aging(lruvec, seq, swappiness, opt); break; case '-': err = run_eviction(lruvec, seq, sc, swappiness, opt); From patchwork Wed Feb 14 06:05:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinsey Ho X-Patchwork-Id: 200816 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp1014948dyb; Tue, 13 Feb 2024 22:07:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVqDR2dVEJGAe5h4UAGehpO3bf8X0d/aBzkWuH6HCAx2z9MD+bNzYlzc/Y4S0Z4rI4wpsk8Zwh/dovbb5XhlSpP1t4k4Q== X-Google-Smtp-Source: AGHT+IFM+SK2BFaCP/++PFrHV6rD/QcjeYmfEPfKwyLueAb50YTy9D5PQdtzoF4g1PA7lqR53aSQ X-Received: by 2002:a17:903:41c5:b0:1db:3076:21e3 with SMTP id u5-20020a17090341c500b001db307621e3mr1754147ple.56.1707890860917; Tue, 13 Feb 2024 22:07:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707890860; cv=pass; d=google.com; s=arc-20160816; b=FV6czLH6Kn18YY/oVuIgkHL5pY8lddYFWhCPr6w5anjSGG0vOdGHoeyv4VK5onu9ll uqYcPI5k+I3RGf+lud1H72piEB12wT9gr6Q6DCujvqOdqBWA6itagA+mhz5Cu4B/3g+Y 4pLB98WYLxFrgS6/x8X/tNgNAhixo2S+cFpBRsCkB53+CIxQ1y4jnBX05kQSo4ge1epb G7/yvw3L5NYJhpVmzU5AKkIEGMo2LMzt2sDnMAQ046Cb51cjWboDb9CvSmRBKfMe62TM +CyFfs50QBt3FUZY1cFasNoXXQ9ORTcpl4vR+CQDLQ2hN26Pp/2fK7bTa+N5mRndWx2P R7Dw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=oan+94DZASviMy6e/v6AGJHUkNS1XGpMmnaov86Qm34=; fh=0uSBxL8/6kIhGrBc0gG4QHguPOxD09PnVa4rpE7CvAU=; b=fu/2UoMVs9bnUp3BPTrXT8r3wYXcGW9XiRFuoyUvB6EJGF1bYNskqodyVrgpPpgOf8 RctLqLKbWhxp+eQoDii/Rlays8c7yC70DBHQAclHr/GbwkvwsqgMOA3wiQVTGKX4Zbpi rqeuX8kgNLpKCsQyk5DV+Iw9pmebIP2hvmlZEkCQ4rg/56ik0MxgnZC+YhFHNmB21JzG jQDD4UXCLoLQjULhGzIWq6B5p1T3zswEzcGJYtVmQ5GJmn5NKBaSmn8YFWGy3suAyBZ6 q8ATXG6oABRgIJUdTeYAGm+DDdoHi3w4C+Bc81yNO4HC8o+BRPQOWlhZxQvJhfY0NXcy bn4Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=KnlYhY3Q; arc=pass (i=1 spf=pass spfdomain=flex--kinseyho.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-64768-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64768-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCULyNBTXhx1dCGy+L9IgaHAfoit8kwpumM7yy8qveFE+OcQDvqn60C01UQg2OrJZdogBKpWjZf3erjDbIvcwh/hEG6UiA== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id w4-20020a170902d3c400b001db5079b71csi1138264plb.598.2024.02.13.22.07.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 22:07:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64768-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=KnlYhY3Q; arc=pass (i=1 spf=pass spfdomain=flex--kinseyho.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-64768-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64768-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 72A0D28E1CF for ; Wed, 14 Feb 2024 06:06:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7F838125CF; Wed, 14 Feb 2024 06:06:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="KnlYhY3Q" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BAE3111BE for ; Wed, 14 Feb 2024 06:06:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707890763; cv=none; b=QWoReFhF6HxtyXWduIwTEYKOw/e6FUti8zfEVHEWqGl5z/jZBiqQ5ptbBiZmUhntRHumWe/j8pY9fsh93k9genng/PfgVyw2HDYzpXvHw+p8/nDzC68PeIMEntV8SgCkamUNZ1VpcKsO/7Lq6kI/FFSWesXV0FOsuFBGfuzm6tg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707890763; c=relaxed/simple; bh=T/QGXqkR1FvOAuC5zznScAzCN6HFAcM6dUi3a9AX+sw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=TP0aqG/aKi3LlPcOo3UhZMIEth/k+I8VCUOZElHWjfAC+3NNhUBvBI9xLNGmjgfEGlXgv2lRSdGgpGt6wT833W52eZBB98YA/CRva/cLJ7vJ1A3AwkWCeyVtJnmqXYvRoyFT/wpFUdl+8F5aeObl9p0aEzb+uO5jlfJnX4rdBRc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--kinseyho.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=KnlYhY3Q; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--kinseyho.bounces.google.com Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dc3645a6790so9467916276.0 for ; Tue, 13 Feb 2024 22:06:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707890761; x=1708495561; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=oan+94DZASviMy6e/v6AGJHUkNS1XGpMmnaov86Qm34=; b=KnlYhY3QcWeDvbOKhL5WnPWBsWV4a1i7L6Tjo4XmvoRndsskAZf39tTyPeH5mPyld8 kRVU3z2ep1UTdv75VhPCpF6XmXC2puL94HcV5Bc5VULB3W70tjOW0uIF4zjgWcFA7GA8 oX7vpYtW/Ix02MIqRdJwEdQ2hz/S8geSp0hStnNjCglnazEiItuiahkZqweuhbkAsR4L FGelscy0th2vaDlTKhN2WsJdUc+Ba8R4O8M2t5cTUpZqPD1Gz6JKXoG0kehPhP5624Jq CG87dOOmxPCVRI6owehaXr91E9VABYun0xs1AnERSWBTlqWXeRPPd565e9RCQ96Hr3w+ qtag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707890761; x=1708495561; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=oan+94DZASviMy6e/v6AGJHUkNS1XGpMmnaov86Qm34=; b=FxOdf8GdQTiP33+VzyF4I54cqnCN1H6TPS/RtZXhvhssS7RnUxUsrtsD3yEiMhb3+s X64j8XXJkeZ5aZWYBU6ncov8VPv8nnjqM+zz6fAep+jvAea/no3QzzGDB2EfkRyWGcJH Jh88AYl/TD3ke3clWCj5uJnoPNP/JE4fEFyvx8DWeall+2Q4D0VAlRZM5/dXGP9qYUuL n6cjpQGshKRRIZ5Jo937/C3FKydVAkwX+mJme+98Z1J0HrqlTjwapf6dTshruNkZK8Yp yuZpCP6EjefFSMxXgFzil2lYbcVBV7PX++wegciYg8TvW42UURPGQ9GjVSyPTmZknq90 hi5g== X-Forwarded-Encrypted: i=1; AJvYcCUl93Yyo2PPdGJZspcO6uFjfpyV9SGD71NReKUyxLXKR66jT+f4e6TY3t5aGTvo4yOCzReDLxwQbXhyfjTE4U4tPX9Vh66CgoZqepx6 X-Gm-Message-State: AOJu0Yw6/XSmE3SzE4o7iYiNoFfpRiIW1SN+LvlofHDJLhLjiLV+i/pK lmZJvyr0FkMHf60x6+0zZWzjy0kuBBwR+9Djti7QZDzvXvYuAVZuroRp8sknUypBK1kk4N3CFIE Rt3NXAJgJSw== X-Received: from kinseyct.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:46b]) (user=kinseyho job=sendgmr) by 2002:a25:698d:0:b0:dca:33b8:38d7 with SMTP id e135-20020a25698d000000b00dca33b838d7mr320126ybc.11.1707890761264; Tue, 13 Feb 2024 22:06:01 -0800 (PST) Date: Wed, 14 Feb 2024 06:05:35 +0000 In-Reply-To: <20240214060538.3524462-1-kinseyho@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240214060538.3524462-1-kinseyho@google.com> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog Message-ID: <20240214060538.3524462-3-kinseyho@google.com> Subject: [PATCH mm-unstable v1 2/5] mm/mglru: improve should_run_aging() From: Kinsey Ho To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yu Zhao , Donet Tom , "Aneesh Kumar K . V" , Kinsey Ho X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790853367374984942 X-GMAIL-MSGID: 1790853367374984942 scan_control *sc does not need to be passed into should_run_aging(), as it provides only the reclaim priority. This can be moved to get_nr_to_scan(). Refactor should_run_aging() and get_nr_to_scan() to improve code readability. No functional changes. Signed-off-by: Kinsey Ho --- mm/vmscan.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 9d15648561ec..87de39e7410b 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -4602,14 +4602,13 @@ static int evict_folios(struct lruvec *lruvec, struct scan_control *sc, int swap } static bool should_run_aging(struct lruvec *lruvec, unsigned long max_seq, - struct scan_control *sc, bool can_swap, unsigned long *nr_to_scan) + bool can_swap, unsigned long *nr_to_scan) { int gen, type, zone; unsigned long old = 0; unsigned long young = 0; unsigned long total = 0; struct lru_gen_folio *lrugen = &lruvec->lrugen; - struct mem_cgroup *memcg = lruvec_memcg(lruvec); DEFINE_MIN_SEQ(lruvec); /* whether this lruvec is completely out of cold folios */ @@ -4637,13 +4636,7 @@ static bool should_run_aging(struct lruvec *lruvec, unsigned long max_seq, } } - /* try to scrape all its memory if this memcg was deleted */ - if (!mem_cgroup_online(memcg)) { - *nr_to_scan = total; - return false; - } - - *nr_to_scan = total >> sc->priority; + *nr_to_scan = total; /* * The aging tries to be lazy to reduce the overhead, while the eviction @@ -4675,6 +4668,7 @@ static bool should_run_aging(struct lruvec *lruvec, unsigned long max_seq, */ static long get_nr_to_scan(struct lruvec *lruvec, struct scan_control *sc, bool can_swap) { + bool success; unsigned long nr_to_scan; struct mem_cgroup *memcg = lruvec_memcg(lruvec); DEFINE_MAX_SEQ(lruvec); @@ -4682,14 +4676,17 @@ static long get_nr_to_scan(struct lruvec *lruvec, struct scan_control *sc, bool if (mem_cgroup_below_min(sc->target_mem_cgroup, memcg)) return -1; - if (!should_run_aging(lruvec, max_seq, sc, can_swap, &nr_to_scan)) - return nr_to_scan; + success = should_run_aging(lruvec, max_seq, can_swap, &nr_to_scan); - /* skip the aging path at the default priority */ - if (sc->priority == DEF_PRIORITY) + /* try to scrape all its memory if this memcg was deleted */ + if (nr_to_scan && !mem_cgroup_online(memcg)) return nr_to_scan; - /* skip this lruvec as it's low on cold folios */ + /* try to get away with not aging at the default priority */ + if (!success || sc->priority == DEF_PRIORITY) + return nr_to_scan >> sc->priority; + + /* stop scanning this lruvec as it's low on cold folios */ return try_to_inc_max_seq(lruvec, max_seq, can_swap, false) ? -1 : 0; } From patchwork Wed Feb 14 06:05:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinsey Ho X-Patchwork-Id: 200817 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp1014992dyb; Tue, 13 Feb 2024 22:07:48 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUg22GU42ODM0NY7YiCwAy2ihuixw8TNkADxY+9Sx3rxU1L4zSQtM9fcP30FKiSJlGQyP4Q6r/x0Q38sisbsF+xsKTPJA== X-Google-Smtp-Source: AGHT+IFf1Qe8eEe5WcKIKROkutrWDyFOJN3v9RK6dFN3Zya/l2w3Fqm+N+LO+mOGHKD0VYLZ3lF2 X-Received: by 2002:a05:6402:4582:b0:55f:ce14:337a with SMTP id ig2-20020a056402458200b0055fce14337amr699359edb.11.1707890868001; Tue, 13 Feb 2024 22:07:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707890867; cv=pass; d=google.com; s=arc-20160816; b=roer2GOV1Z14xO3Xwvz5L53SRYD2fJhXPQZupJQD/smMM4u4mEXexg4ssnwX0IFcLp xlg1sLwrDVXNfTIvGculjBT0AXrIyFyDeC6JGLJcyxp8Sa3/xSiXwjnjFOTGdeCb9eAL P29DT/9MwprVU3SL5OHuE8nof6DlX8P7a7pKMgRamj6kKXs4XfvOvriS7B+T+0GBGGvC 258fomocGHfpRt2OxQuJCfZalRyzXh423aZhezKldWeyEChY6DqfI5qACho6QhLLidMP e3hlks7s7fXamN6BdBSashkoXGnpT1kSZvUWBnHhgjQ9p6brA+y9x82VnmSIZOLndkPF T34g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=WP4kkPaAqTjN0MzajVa9lPmQ9VDuB302oaofmpmGZdQ=; fh=FtS27TD0Qxn97MduDR5/oA0eaf4XpwMpDMD7RVQujaM=; b=uiBRlRh7I11kIIIyszEBbm+gjiPzhYw78u2sMACh7HyPFUJY2XYEIdhVaLVsc9vRgR 7+De8bcHDqd1n8+SxyPFTFhbFnmbUyq3fFmETd8c/GFSvbCy0MVgbXWw3Sq3ADZ/tshy rqKhIlKnWO216XwiWNN5/hVWrqMneOJc99kSc1Df91hddR4ZlzfU2nzIcYxasOT5Go56 7VTkNU1mLvNQG8ytw30Dd9tm6RilLMzZs1MWWVxfjcf6c7jYlqJtDpohzkyhXF/br93O +ls/otskEEIgXOfHsv8qAhiC45sPAv3hZEQgKU/7YOMzqj5P9oh3Bl9ZVisbvGwHXKiP gQWA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="og/fa3q+"; arc=pass (i=1 spf=pass spfdomain=flex--kinseyho.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-64769-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64769-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCXbf9bP4Oq/JeoiVr3J4SbrKIqlB8pGc3rIoBOvDWQ+uxfyjTfMdj2l97bJqALV6P3ljApXukFzGBtoduNF3VHO9T6A5Q== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id y19-20020a056402135300b0056022a0d6e5si4515529edw.466.2024.02.13.22.07.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 22:07:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64769-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="og/fa3q+"; arc=pass (i=1 spf=pass spfdomain=flex--kinseyho.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-64769-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64769-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 3956D1F29DAE for ; Wed, 14 Feb 2024 06:07:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5BEE112B8A; Wed, 14 Feb 2024 06:06:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="og/fa3q+" Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B84D611C80 for ; Wed, 14 Feb 2024 06:06:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707890765; cv=none; b=gmnTCvS7IdSOKnwpsN/BkPcF1wl7OoZGUK4r1xqPfxhNxKmYjNizk6V46ZgTuqZ5PBNqIjy7ASOttEusR3xVf7SLtaUbiXM/mPeRLNGkYN8I5ZULdbFUcBtWFNasiyujsJOqUzlikQwIsJ1QMxSo8kjv+j7O0eqkUFn3DwsRNA0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707890765; c=relaxed/simple; bh=zA3vgExuReWUwe5vdIcTKP6pAnPF79HFJPWi4qGi0jU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=abNElxGdT1HHZkNeZuWcsFXDLUTWgSWqylyGdaOeQRLy7jga1zYNC0miYhwEH2quq+r+oIOMQv6rHx9bC6voJK+PNvpPh/sTW6dkusQM7bTjQt2OpKKVFKoZGRr3OWd0L92eazuLtr+zNhSYFTuG3VfccTrV6Z4QewMPZEy1vE8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--kinseyho.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=og/fa3q+; arc=none smtp.client-ip=209.85.216.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--kinseyho.bounces.google.com Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2968956dd6bso4119601a91.3 for ; Tue, 13 Feb 2024 22:06:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707890763; x=1708495563; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=WP4kkPaAqTjN0MzajVa9lPmQ9VDuB302oaofmpmGZdQ=; b=og/fa3q+/vVkZb61SJYy6oVjejOH6UhXWPEfnudR8kxMeEwEsTu09lfHfpNFUKFJEL IFCBxy64VaD/puAWhtlIm9sq+KomDcwPQvjOeY4I9BZs2j1dPXNoG8mXtKa/vBahK/pY nO8UoKqoXigybb7QqG8yeAvwv9q16ng6le9uGvJ6ak0hZPO1/vxEds+iz8u9HMGhrmCa dllT48ouG/tR0d2TQ78ABZov2lW5NiLRcft8igHWxcM0aiYHNeutGa2Lh8sllBb9bThe Q0wF8zy0JJ6X+T2V7jmj4tBQ+Mwgc7ibIArURSGAzKtmm17Efi3ZVPS4jqNs0d8oCJns Vjsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707890763; x=1708495563; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WP4kkPaAqTjN0MzajVa9lPmQ9VDuB302oaofmpmGZdQ=; b=sZV+cIOHuu3Ib8YMZMKIYK4d7SACa0UbeDwKrPGgq1V8DupfsOKAJhEKqBQLI0OsyP 41SDW6pahLawEDYWlfHnOumtLO8b9gJ5QH48BYUVzvv+khE8eF3bZqLLb0xz4p0TW0tk 9jjrSpi3b7gqJBJGi0o0ScWEfvncR6zlPYNHMACoHDHhBJiotH1X4jmzLhZg+bZzT/9b PziUqf30CfGCbA9OJj+xwOFT4HvECKXhQbDQxkRlKfwFXcgbJ6kVuK7iFHcGppNUuwah CP0u2EtxVREPyUdEBqPghqVUxO2VPP6Vc/lPIjqlcgcOq23TByl7M2nq7sIIIHk4p6zP xfrQ== X-Forwarded-Encrypted: i=1; AJvYcCWKphPY04sLSrpBH9fsxl1uSiwTz5uIwywQn2FFSIoaI4w8Ak2wK0+NGvw31ov1SJDp2VRsVYYlmq8fqXyaOl9B6LylWfKNj4NpG8SD X-Gm-Message-State: AOJu0YyFnqkaZc5UR5HfwpC6Hq4FvzKLCRuNr8AlmC0L4IN/vRhgpi9P SXxjOlBGl1uHyRkwb7ZwdaFUGq6dhlAX/6Sy8oaNg58bN9vtYLH6kReLsge8MSUifOUW/sdautk +PwPu0Z3++w== X-Received: from kinseyct.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:46b]) (user=kinseyho job=sendgmr) by 2002:a17:90b:4ccd:b0:298:966f:e7e1 with SMTP id nd13-20020a17090b4ccd00b00298966fe7e1mr38390pjb.4.1707890763039; Tue, 13 Feb 2024 22:06:03 -0800 (PST) Date: Wed, 14 Feb 2024 06:05:36 +0000 In-Reply-To: <20240214060538.3524462-1-kinseyho@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240214060538.3524462-1-kinseyho@google.com> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog Message-ID: <20240214060538.3524462-4-kinseyho@google.com> Subject: [PATCH mm-unstable v1 3/5] mm/mglru: improve reset_mm_stats() From: Kinsey Ho To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yu Zhao , Donet Tom , "Aneesh Kumar K . V" , Kinsey Ho X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790853374809526741 X-GMAIL-MSGID: 1790853374809526741 struct lruvec* is already a field of struct lru_gen_mm_walk. Remove the parameter struct lruvec* into functions that already have access to struct lru_gen_mm_walk*. Also, we do not need to handle reset histogram stats when !should_walk_mmu(). Remove the call to reset_mm_stats() in iterate_mm_list_nowalk(). Signed-off-by: Kinsey Ho --- mm/vmscan.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 87de39e7410b..8c77c332a67a 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2897,38 +2897,37 @@ static struct mm_struct *get_next_mm(struct lru_gen_mm_walk *walk) #endif -static void reset_mm_stats(struct lruvec *lruvec, struct lru_gen_mm_walk *walk, bool last) +static void reset_mm_stats(struct lru_gen_mm_walk *walk, bool last) { int i; int hist; + struct lruvec *lruvec = walk->lruvec; struct lru_gen_mm_state *mm_state = get_mm_state(lruvec); lockdep_assert_held(&get_mm_list(lruvec_memcg(lruvec))->lock); - if (walk) { - hist = lru_hist_from_seq(walk->max_seq); + hist = lru_hist_from_seq(walk->max_seq); - for (i = 0; i < NR_MM_STATS; i++) { - WRITE_ONCE(mm_state->stats[hist][i], - mm_state->stats[hist][i] + walk->mm_stats[i]); - walk->mm_stats[i] = 0; - } + for (i = 0; i < NR_MM_STATS; i++) { + WRITE_ONCE(mm_state->stats[hist][i], + mm_state->stats[hist][i] + walk->mm_stats[i]); + walk->mm_stats[i] = 0; } if (NR_HIST_GENS > 1 && last) { - hist = lru_hist_from_seq(mm_state->seq + 1); + hist = lru_hist_from_seq(walk->max_seq + 1); for (i = 0; i < NR_MM_STATS; i++) WRITE_ONCE(mm_state->stats[hist][i], 0); } } -static bool iterate_mm_list(struct lruvec *lruvec, struct lru_gen_mm_walk *walk, - struct mm_struct **iter) +static bool iterate_mm_list(struct lru_gen_mm_walk *walk, struct mm_struct **iter) { bool first = false; bool last = false; struct mm_struct *mm = NULL; + struct lruvec *lruvec = walk->lruvec; struct mem_cgroup *memcg = lruvec_memcg(lruvec); struct lru_gen_mm_list *mm_list = get_mm_list(memcg); struct lru_gen_mm_state *mm_state = get_mm_state(lruvec); @@ -2972,7 +2971,7 @@ static bool iterate_mm_list(struct lruvec *lruvec, struct lru_gen_mm_walk *walk, } while (!(mm = get_next_mm(walk))); done: if (*iter || last) - reset_mm_stats(lruvec, walk, last); + reset_mm_stats(walk, last); spin_unlock(&mm_list->lock); @@ -3002,7 +3001,6 @@ static bool iterate_mm_list_nowalk(struct lruvec *lruvec, unsigned long max_seq) mm_state->head = NULL; mm_state->tail = NULL; WRITE_ONCE(mm_state->seq, mm_state->seq + 1); - reset_mm_stats(lruvec, NULL, true); success = true; } @@ -3177,9 +3175,10 @@ static void update_batch_size(struct lru_gen_mm_walk *walk, struct folio *folio, walk->nr_pages[new_gen][type][zone] += delta; } -static void reset_batch_size(struct lruvec *lruvec, struct lru_gen_mm_walk *walk) +static void reset_batch_size(struct lru_gen_mm_walk *walk) { int gen, type, zone; + struct lruvec *lruvec = walk->lruvec; struct lru_gen_folio *lrugen = &lruvec->lrugen; walk->batched = 0; @@ -3609,7 +3608,7 @@ static int walk_pud_range(p4d_t *p4d, unsigned long start, unsigned long end, return -EAGAIN; } -static void walk_mm(struct lruvec *lruvec, struct mm_struct *mm, struct lru_gen_mm_walk *walk) +static void walk_mm(struct mm_struct *mm, struct lru_gen_mm_walk *walk) { static const struct mm_walk_ops mm_walk_ops = { .test_walk = should_skip_vma, @@ -3618,6 +3617,7 @@ static void walk_mm(struct lruvec *lruvec, struct mm_struct *mm, struct lru_gen_ }; int err; + struct lruvec *lruvec = walk->lruvec; struct mem_cgroup *memcg = lruvec_memcg(lruvec); walk->next_addr = FIRST_USER_ADDRESS; @@ -3646,7 +3646,7 @@ static void walk_mm(struct lruvec *lruvec, struct mm_struct *mm, struct lru_gen_ if (walk->batched) { spin_lock_irq(&lruvec->lru_lock); - reset_batch_size(lruvec, walk); + reset_batch_size(walk); spin_unlock_irq(&lruvec->lru_lock); } @@ -3874,9 +3874,9 @@ static bool try_to_inc_max_seq(struct lruvec *lruvec, unsigned long max_seq, walk->force_scan = force_scan; do { - success = iterate_mm_list(lruvec, walk, &mm); + success = iterate_mm_list(walk, &mm); if (mm) - walk_mm(lruvec, mm, walk); + walk_mm(mm, walk); } while (mm); done: if (success) { @@ -4576,8 +4576,10 @@ static int evict_folios(struct lruvec *lruvec, struct scan_control *sc, int swap move_folios_to_lru(lruvec, &list); walk = current->reclaim_state->mm_walk; - if (walk && walk->batched) - reset_batch_size(lruvec, walk); + if (walk && walk->batched) { + walk->lruvec = lruvec; + reset_batch_size(walk); + } item = PGSTEAL_KSWAPD + reclaimer_offset(); if (!cgroup_reclaim(sc)) From patchwork Wed Feb 14 06:05:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinsey Ho X-Patchwork-Id: 200818 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp1015599dyb; Tue, 13 Feb 2024 22:09:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXd4f1b96RLZlKwcXni2ZnfW2yAW/8xVgWOqU7DplloNw0JGlJ/mr5jgOIPmRJVudjHvEdrM77mxUQAlN4WVOtMz47mCA== X-Google-Smtp-Source: AGHT+IHIdynbCoIM/sUR6G0QxbfJQt3i6zUa8hQDBx73RhpIf4Vp4kthbIR8Buab0EXC+XlHtGmm X-Received: by 2002:a05:6358:5799:b0:176:55c4:ad94 with SMTP id m25-20020a056358579900b0017655c4ad94mr2245143rwf.8.1707890971555; Tue, 13 Feb 2024 22:09:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707890971; cv=pass; d=google.com; s=arc-20160816; b=JKJhaZ1yi6pYh52KR20bN0NSCC6GsIdLSDS/7sbT5lmB4w0wF8/0sTyW6vTONFZNLc 8s/GZw43JsnZ/8IQcByfDzut6d1+2k3jSzzJkdJBTVOvRGRKpOG1epuWy/uMW/MDG4h3 y9hwWEt137jrY+MQHRdB+504ELjxaOiCOhZxgPiQmJN+6eq6WG6QMUM9RZ+bJddJn3Gn BrS2bCkc/3Dl8DBFG+se/ALQWZSOXwEGxdwRATct5v/OTr/Uziw5H0EzggFR7MXOwvGD LO4zlqZ1csPlV93ilMcMHfWZi2xk6+HXAWy9AfIp8HMO8Hbnqa3a0RqYEHGOVi7EH/Sh ojPQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=QH8wNJ7lAHDhvm3bFylVV17pyKkkH6HT7TXZodNBMaI=; fh=XKRr1XpCdNizsmsBK8rZU830qWJhcudgITR7iljmr3c=; b=ZC7UBA1VnlROPrUjGXRszD7NE88cyHgFVZxym2KuSFMBFJKEuR6S4hCIsGnHDb6Sse w1rNs+dHXFUgziffQU7M7MMU6mjiVmAjBEKrxP3I9hrxzdTlaGpflgjmfpeF4my+tGAa 5Oql1UNyTXJtX2Bg7F0oNVC5moy869mi4NipoFc3f+fqy2wrDw1mCyrJNyBVmUMh8Zgw KtSlORx4R9PkHbRYJGxbcIgncHiyA4bAkuuSmqwnfSUZb07Zqof5v0h56fVLLisgxjFu UaLgY93aoCfiG2JbCuJvo8MxlI0S8NoLOKjaUNLqMVixccDicsKmNEIwwT4pfxa8Ce2b ZnwA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="wY1I/0ng"; arc=pass (i=1 spf=pass spfdomain=flex--kinseyho.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-64770-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64770-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCUunuNqKIImpQ2NY4FQHc0oI3uzYqp0BqXg+NG/naMDIPa1qPGwGHuC4RsREcUnQ0vQ+fNs038X15VxHByfe4yL/5lAuw== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id b26-20020a63715a000000b005d6c2958481si3190672pgn.639.2024.02.13.22.09.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 22:09:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64770-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="wY1I/0ng"; arc=pass (i=1 spf=pass spfdomain=flex--kinseyho.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-64770-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64770-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id BC890B28C89 for ; Wed, 14 Feb 2024 06:07:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E4A84134D1; Wed, 14 Feb 2024 06:06:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="wY1I/0ng" Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E904125B1 for ; Wed, 14 Feb 2024 06:06:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707890767; cv=none; b=RXVrPB1JXd4Vhfq1MUeE9vvBzLv31S5TNulplVaQCYgmOI5B3dJzctJSBrs40yUc8f9QfvtJ5svqCuTEew0MoZmE2Qa3z6lYYACSWPvLav5avHwCLE3CTDvicuJHcH3ZYJ9Ns/yjV3LTT86xBbxNRZT7yShp8i6a1Tkdx1aLoPw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707890767; c=relaxed/simple; bh=N9V0u3Ch6t/WSSGIrkB/hnLuxMA5NOlPuGRvTZgM1xU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=dG3SwRYVS5/zY9SUJmWQObwVoZdPOSRSN0/HvOFa1rHREfwmSbrv+gvEH72MCcImPFL0dvubAyexniwSnTozAgaRyOhKkcEqSKeiCmS+9F6fF1ykZLfjlUkaw4+2AqVOAsFdVIdtkvxrE1/q3b/SvdnWM9IYvWwC8+7QFG3ekn0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--kinseyho.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=wY1I/0ng; arc=none smtp.client-ip=209.85.210.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--kinseyho.bounces.google.com Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-6e09015f811so5954067b3a.0 for ; Tue, 13 Feb 2024 22:06:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707890765; x=1708495565; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=QH8wNJ7lAHDhvm3bFylVV17pyKkkH6HT7TXZodNBMaI=; b=wY1I/0ng2hVYWb4vthSvyheDQnCI1i6k0vFospCrhnotctDssViM/npp5seNlWu2NM 32ruKaifotutq2sO3dqijdU0/Gp4H40hRdnUFGRAYxV+XPYfnWUXivzJYRMKihc1LJa4 vUdiQCwi1e/HEB460zT+PIZfrmCT+tQynCS/H2Vlm/n/nu79MYB33TJyyH39edztJLBr eVAnKMwYMZo0SOhER6roD8n3oBTBStuz+cA3rIqFWK9MKV3oOHvBxEGFvmQfx4+6AqqC qJVZl/T/T8sJ5yHhmES4bCfaP1oBMFBZDyG6+yUU6RJbhXlSxPMIa8Uj8G0ttYpcIOI6 AxKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707890765; x=1708495565; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QH8wNJ7lAHDhvm3bFylVV17pyKkkH6HT7TXZodNBMaI=; b=p4MHeh/ufvsKh39QNwmyiBygjiWMqMt/UvlG1nQy3plxiKKqIEcSdyIRTUOCLYc0+8 nGpxIJu8BgXUPjHXvELzRHzw7olySwYyXqZ3OyeCPYWEzix6hvrG+GJ/74hSx8ZURmi/ KXBz9YNwYaYjoHFgD88nY6O4Dk+zeYq6TBEFbFofxc/uPBiRIYHL5pR/QfHazPtezIal LDSOwVf9IubtdmVN5VtpGvzrK3uN4J8Qn8vTZ1jPy481kEi4efVsQP8My8FfYBh1pyiX iSFl2JT+oSq9/8mR060/W5coo3SBBOvCM/wVG4AipZnkvRhaV8VcHXeh8l/xTEZK+s0C 6MWA== X-Forwarded-Encrypted: i=1; AJvYcCWv7MGMS1QbXcN0o2ps+iD4cKQnIcvyu29T0gSC47Ca2BA66CIXxdDhEo0p9kcdmO4g0xLLdf4rV4/SJVMNeieg9oCHU0ewEQsNnMAF X-Gm-Message-State: AOJu0YwhBLPy2C1irbldv4nF0ZXIh6rSZBo9tgYn2hid8xioJKus/WzS RPP9/SzYjzCGXz6yw0Cwu9lGoBSblHa1BuUs0a6I4B1/IOPNU0EAS15xxMbu90Drl/ljpR4mUm6 w/Czv11bEeg== X-Received: from kinseyct.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:46b]) (user=kinseyho job=sendgmr) by 2002:a05:6a00:2d9e:b0:6e0:a9bc:ef63 with SMTP id fb30-20020a056a002d9e00b006e0a9bcef63mr112938pfb.0.1707890764929; Tue, 13 Feb 2024 22:06:04 -0800 (PST) Date: Wed, 14 Feb 2024 06:05:37 +0000 In-Reply-To: <20240214060538.3524462-1-kinseyho@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240214060538.3524462-1-kinseyho@google.com> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog Message-ID: <20240214060538.3524462-5-kinseyho@google.com> Subject: [PATCH mm-unstable v1 4/5] mm/mglru: improve struct lru_gen_mm_walk From: Kinsey Ho To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yu Zhao , Donet Tom , "Aneesh Kumar K . V" , Kinsey Ho X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790853483204079189 X-GMAIL-MSGID: 1790853483204079189 Rename max_seq to seq in struct lru_gen_mm_walk to keep consistent with struct lru_gen_mm_state. Note that seq is not always up to date with max_seq from lru_gen_folio. No functional changes. Signed-off-by: Kinsey Ho --- include/linux/mmzone.h | 6 ++--- mm/vmscan.c | 50 ++++++++++++++++++++++-------------------- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 22fd46c77840..e51c75270e82 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -468,7 +468,7 @@ enum { #define NR_BLOOM_FILTERS 2 struct lru_gen_mm_state { - /* set to max_seq after each iteration */ + /* synced with max_seq after each iteration */ unsigned long seq; /* where the current iteration continues after */ struct list_head *head; @@ -483,8 +483,8 @@ struct lru_gen_mm_state { struct lru_gen_mm_walk { /* the lruvec under reclaim */ struct lruvec *lruvec; - /* unstable max_seq from lru_gen_folio */ - unsigned long max_seq; + /* max_seq from lru_gen_folio: can be out of date */ + unsigned long seq; /* the next address within an mm to scan */ unsigned long next_addr; /* to batch promoted pages */ diff --git a/mm/vmscan.c b/mm/vmscan.c index 8c77c332a67a..f1019afa7813 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2906,7 +2906,7 @@ static void reset_mm_stats(struct lru_gen_mm_walk *walk, bool last) lockdep_assert_held(&get_mm_list(lruvec_memcg(lruvec))->lock); - hist = lru_hist_from_seq(walk->max_seq); + hist = lru_hist_from_seq(walk->seq); for (i = 0; i < NR_MM_STATS; i++) { WRITE_ONCE(mm_state->stats[hist][i], @@ -2915,7 +2915,7 @@ static void reset_mm_stats(struct lru_gen_mm_walk *walk, bool last) } if (NR_HIST_GENS > 1 && last) { - hist = lru_hist_from_seq(walk->max_seq + 1); + hist = lru_hist_from_seq(walk->seq + 1); for (i = 0; i < NR_MM_STATS; i++) WRITE_ONCE(mm_state->stats[hist][i], 0); @@ -2944,9 +2944,9 @@ static bool iterate_mm_list(struct lru_gen_mm_walk *walk, struct mm_struct **ite */ spin_lock(&mm_list->lock); - VM_WARN_ON_ONCE(mm_state->seq + 1 < walk->max_seq); + VM_WARN_ON_ONCE(mm_state->seq + 1 < walk->seq); - if (walk->max_seq <= mm_state->seq) + if (walk->seq <= mm_state->seq) goto done; if (!mm_state->head) @@ -2976,7 +2976,7 @@ static bool iterate_mm_list(struct lru_gen_mm_walk *walk, struct mm_struct **ite spin_unlock(&mm_list->lock); if (mm && first) - reset_bloom_filter(mm_state, walk->max_seq + 1); + reset_bloom_filter(mm_state, walk->seq + 1); if (*iter) mmput_async(*iter); @@ -2986,7 +2986,7 @@ static bool iterate_mm_list(struct lru_gen_mm_walk *walk, struct mm_struct **ite return last; } -static bool iterate_mm_list_nowalk(struct lruvec *lruvec, unsigned long max_seq) +static bool iterate_mm_list_nowalk(struct lruvec *lruvec, unsigned long seq) { bool success = false; struct mem_cgroup *memcg = lruvec_memcg(lruvec); @@ -2995,9 +2995,9 @@ static bool iterate_mm_list_nowalk(struct lruvec *lruvec, unsigned long max_seq) spin_lock(&mm_list->lock); - VM_WARN_ON_ONCE(mm_state->seq + 1 < max_seq); + VM_WARN_ON_ONCE(mm_state->seq + 1 < seq); - if (max_seq > mm_state->seq) { + if (seq > mm_state->seq) { mm_state->head = NULL; mm_state->tail = NULL; WRITE_ONCE(mm_state->seq, mm_state->seq + 1); @@ -3348,7 +3348,8 @@ static bool walk_pte_range(pmd_t *pmd, unsigned long start, unsigned long end, struct lru_gen_mm_walk *walk = args->private; struct mem_cgroup *memcg = lruvec_memcg(walk->lruvec); struct pglist_data *pgdat = lruvec_pgdat(walk->lruvec); - int old_gen, new_gen = lru_gen_from_seq(walk->max_seq); + DEFINE_MAX_SEQ(walk->lruvec); + int old_gen, new_gen = lru_gen_from_seq(max_seq); pte = pte_offset_map_nolock(args->mm, pmd, start & PMD_MASK, &ptl); if (!pte) @@ -3415,7 +3416,8 @@ static void walk_pmd_range_locked(pud_t *pud, unsigned long addr, struct vm_area struct lru_gen_mm_walk *walk = args->private; struct mem_cgroup *memcg = lruvec_memcg(walk->lruvec); struct pglist_data *pgdat = lruvec_pgdat(walk->lruvec); - int old_gen, new_gen = lru_gen_from_seq(walk->max_seq); + DEFINE_MAX_SEQ(walk->lruvec); + int old_gen, new_gen = lru_gen_from_seq(max_seq); VM_WARN_ON_ONCE(pud_leaf(*pud)); @@ -3546,7 +3548,7 @@ static void walk_pmd_range(pud_t *pud, unsigned long start, unsigned long end, walk_pmd_range_locked(pud, addr, vma, args, bitmap, &first); } - if (!walk->force_scan && !test_bloom_filter(mm_state, walk->max_seq, pmd + i)) + if (!walk->force_scan && !test_bloom_filter(mm_state, walk->seq, pmd + i)) continue; walk->mm_stats[MM_NONLEAF_FOUND]++; @@ -3557,7 +3559,7 @@ static void walk_pmd_range(pud_t *pud, unsigned long start, unsigned long end, walk->mm_stats[MM_NONLEAF_ADDED]++; /* carry over to the next generation */ - update_bloom_filter(mm_state, walk->max_seq + 1, pmd + i); + update_bloom_filter(mm_state, walk->seq + 1, pmd + i); } walk_pmd_range_locked(pud, -1, vma, args, bitmap, &first); @@ -3628,7 +3630,7 @@ static void walk_mm(struct mm_struct *mm, struct lru_gen_mm_walk *walk) err = -EBUSY; /* another thread might have called inc_max_seq() */ - if (walk->max_seq != max_seq) + if (walk->seq != max_seq) break; /* folio_update_gen() requires stable folio_memcg() */ @@ -3765,7 +3767,7 @@ static bool try_to_inc_min_seq(struct lruvec *lruvec, bool can_swap) return success; } -static bool inc_max_seq(struct lruvec *lruvec, unsigned long max_seq, +static bool inc_max_seq(struct lruvec *lruvec, unsigned long seq, bool can_swap, bool force_scan) { bool success; @@ -3773,14 +3775,14 @@ static bool inc_max_seq(struct lruvec *lruvec, unsigned long max_seq, int type, zone; struct lru_gen_folio *lrugen = &lruvec->lrugen; restart: - if (max_seq < READ_ONCE(lrugen->max_seq)) + if (seq < READ_ONCE(lrugen->max_seq)) return false; spin_lock_irq(&lruvec->lru_lock); VM_WARN_ON_ONCE(!seq_is_valid(lruvec)); - success = max_seq == lrugen->max_seq; + success = seq == lrugen->max_seq; if (!success) goto unlock; @@ -3833,7 +3835,7 @@ static bool inc_max_seq(struct lruvec *lruvec, unsigned long max_seq, return success; } -static bool try_to_inc_max_seq(struct lruvec *lruvec, unsigned long max_seq, +static bool try_to_inc_max_seq(struct lruvec *lruvec, unsigned long seq, bool can_swap, bool force_scan) { bool success; @@ -3842,13 +3844,13 @@ static bool try_to_inc_max_seq(struct lruvec *lruvec, unsigned long max_seq, struct lru_gen_folio *lrugen = &lruvec->lrugen; struct lru_gen_mm_state *mm_state = get_mm_state(lruvec); - VM_WARN_ON_ONCE(max_seq > READ_ONCE(lrugen->max_seq)); + VM_WARN_ON_ONCE(seq > READ_ONCE(lrugen->max_seq)); if (!mm_state) - return inc_max_seq(lruvec, max_seq, can_swap, force_scan); + return inc_max_seq(lruvec, seq, can_swap, force_scan); /* see the comment in iterate_mm_list() */ - if (max_seq <= READ_ONCE(mm_state->seq)) + if (seq <= READ_ONCE(mm_state->seq)) return false; /* @@ -3858,18 +3860,18 @@ static bool try_to_inc_max_seq(struct lruvec *lruvec, unsigned long max_seq, * is less efficient, but it avoids bursty page faults. */ if (!should_walk_mmu()) { - success = iterate_mm_list_nowalk(lruvec, max_seq); + success = iterate_mm_list_nowalk(lruvec, seq); goto done; } walk = set_mm_walk(NULL, true); if (!walk) { - success = iterate_mm_list_nowalk(lruvec, max_seq); + success = iterate_mm_list_nowalk(lruvec, seq); goto done; } walk->lruvec = lruvec; - walk->max_seq = max_seq; + walk->seq = seq; walk->can_swap = can_swap; walk->force_scan = force_scan; @@ -3880,7 +3882,7 @@ static bool try_to_inc_max_seq(struct lruvec *lruvec, unsigned long max_seq, } while (mm); done: if (success) { - success = inc_max_seq(lruvec, max_seq, can_swap, force_scan); + success = inc_max_seq(lruvec, seq, can_swap, force_scan); WARN_ON_ONCE(!success); } From patchwork Wed Feb 14 06:05:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinsey Ho X-Patchwork-Id: 200819 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp1015691dyb; Tue, 13 Feb 2024 22:09:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX51W7nWJgPKMIDC5siwYNLz9Xkvm/SxL2K/6jynghfXyOa0kOserUksqfxotMWlCJFTLLx2+cLhUmyGKqaZJdTm13i/Q== X-Google-Smtp-Source: AGHT+IHJ4xDNXXJVQExyea+53lgZiHu/n4TotmEznrf/XSX8QFkfATGybmMKRhfpY0p9OcgKV8TO X-Received: by 2002:a17:902:fc84:b0:1d9:7ebe:432a with SMTP id mf4-20020a170902fc8400b001d97ebe432amr2081602plb.30.1707890985555; Tue, 13 Feb 2024 22:09:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707890985; cv=pass; d=google.com; s=arc-20160816; b=n6BDHujiWFeCZtCl95yCE5MiGY60PzWhOr6ENY3ZwcNYAhuIwfeqaQQ52MZINPvo6d uM0gH70MPjRu0EMtPeMTSo30V9LbitVEf0w/EqxxQo2iDXNrrO9uqb0+XALYFidAUQQW Jrv/SPv8oBossIQHkshvPc7DIJ++oQlC5/POr9mpVZpY0G+jQyDOcF+q/N/Pl/ITa2E9 CgpxtI26SsJ/CKM7g1mYkOA32+M6jGNUpepGur1Vo7gAexlI+p/pRhdqYgztMEMAvNkZ ttcVmg5OcujOFL3jG3SxXfix3PjwSqm7tk0tVS9SaAZPRiQ5gmNvvWDnS3Hwp99YbrNP Kavw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=g6dfBLL0uVL4kHNX/u5ol8tmo8iu96qepQdMS5ybNno=; fh=hex46nxWKRlprmrTs0sS3DzO5Q1xSvA2AeUfQQ+/Dy0=; b=QMsQhv4h/z56rDCnJl0S3BENDsSCAIKsBbfk6JImSpM68tsEKfqLDJQjnDeMvGYZ4l UgKp7SM+onm1tYnuQvlBzOjjoEJhzBVEuRJYSy6LigYY7anfQsrJ70aPDpg/5d8CLpNq VdnNDCEavrvADrHJEWKQt7iuM9vxEcebxi/KD14hpHear57dUTjt5fOm1kljNFEq/UHc bTY9G2zrhl/SHCwaqG+I+uVu+y4L62JzDuyiOhLqE2V5vBdjS6Z5BRBB+zEWS7WKuIXB lrP0G6bngFrdune4w/qe3X6LvjXZeSGOG1PP9FcXqW+JKbN74MIPCEAfO02vnTaeqq0q 368w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ODbChT5F; arc=pass (i=1 spf=pass spfdomain=flex--kinseyho.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-64771-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64771-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCUulZcyIjeS2Obv+IQMfycxBPQsBPNal4iz52dBUAG2HqTRmJ/WDg5rQ4UHvthKGY+81viLi4xe9UGLsUA54udvkx3Sbg== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id l13-20020a170902f68d00b001d942b506b4si3381833plg.357.2024.02.13.22.09.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 22:09:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64771-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ODbChT5F; arc=pass (i=1 spf=pass spfdomain=flex--kinseyho.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-64771-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64771-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id E1F2CB28DAF for ; Wed, 14 Feb 2024 06:07:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D654D1427F; Wed, 14 Feb 2024 06:06:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ODbChT5F" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96D0812B6D for ; Wed, 14 Feb 2024 06:06:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707890769; cv=none; b=asNbTL6K9LdBsyCsjX4ULQwP8VHazOIv+1WwsMZ1aHQHzAyyi/nNmHPoZOXUmBPFMF8YWF/ETJOSB+aA5RZYmJaVMg3PYrtZ+NEcQyVDSfj5trb+ftNR96ngefjhXSgob5OSKY+IyaB19YZWavEucSOEb8K8N29bB6q7CvabrEA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707890769; c=relaxed/simple; bh=Nn2aC7Sxme7TmKC1R3Wk8wOWqMobubOZoyNWF/vBV5g=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=MrvM8HGc044mcwXBqWt63tn/P5StNmBIGPzpGIEAF4CgO82dSos7dZ7OES6hAP22fMg04cwhaz3TUXvk282WuoPRrXKLbZzMb0OoK0JBdDhWKAv3o4RpXJ8e+7RQlNOzEgOE8RList0y54BvkSVwdAZMvDDGqDV56kDxopwmegA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--kinseyho.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ODbChT5F; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--kinseyho.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dc64f63d768so9592209276.2 for ; Tue, 13 Feb 2024 22:06:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707890766; x=1708495566; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=g6dfBLL0uVL4kHNX/u5ol8tmo8iu96qepQdMS5ybNno=; b=ODbChT5FsP0oX96JxVWgtHoQT/oywaMaxAkMh76Qw8EVQmlp9DwXnYFHwnwVoDKydf 2fUspDR88SYD552K9bn3lZEF3xot/HRMYfl7xUT/KbbTxxcmQ6qZ3FjZi8LTw+HpfxAi P6qFEfmBm5OO7VXMoTXBx/RQKq8CO51DNJdlcp9A9zHz9DYPFt+EP4SsEz1xYcshw9/P Bu/TNTbzIlJUT6JR1QtMBRbcW2F9jdkMKx6XqL0krYuMHutCOYBf791CD2XxMvTKDgm+ KYv/7C3ocsfJIsu0I0HzfwMyH58rTO8FD/Hw86RWH+bgX7RzYm46IyGwWPwKXIW04SIZ DO+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707890766; x=1708495566; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=g6dfBLL0uVL4kHNX/u5ol8tmo8iu96qepQdMS5ybNno=; b=RXznkIOI3jaFEaEad2xMZTyrhIzdl1yiFy0jzYqkS8Egii8WDAp8xJsRzHEldL1tsz 9H6mGfz6VWIuJTrN+Y/BAPIEnes6otwNozxC4klNeIvGiHCCLBhhME6Yd2vI6aLrwCSM LgLij64T/2/LQxl7DG5TPJp+L4yN1dLKg18xLLw/NGGQsgBXKT/xtS/ASJGP5ERtWQIt lLFdR8m0dXTxVqPM8h2DBiTF3PGVihuPxjoHizP6mwYTw4zjxPrID3B2mPqNpBrK80a/ +xM37u0oBeS51MLP7hJucPh1qZfn9jSgnaheHfl7YcqvGt1pdWLthCdtskhREv9g64UW 00yw== X-Forwarded-Encrypted: i=1; AJvYcCXJx+Ul59RrWqll8A+7QmYyvmkLCyAsSs/s57tD7Z6OzFyHu2RxcJ+Nsxt4HnDoFfttBkIalxIxPtv+aOZbMafKb5MKOZkprcNjdjGf X-Gm-Message-State: AOJu0YxlIH0YcntuID+LmVj/DEHMu6uelqAiP4Zs5VGA7MSUs08OxkyP /BU48jWtMuB0Ef25jWot06ISVJFI/xP3DvckydSPrT2L4Uv4ZNqlDdLkC2mDO6zI0hmQJGDD97K W+WCaZpBzJA== X-Received: from kinseyct.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:46b]) (user=kinseyho job=sendgmr) by 2002:a05:6902:1505:b0:dc6:cd85:bcd7 with SMTP id q5-20020a056902150500b00dc6cd85bcd7mr322452ybu.3.1707890766683; Tue, 13 Feb 2024 22:06:06 -0800 (PST) Date: Wed, 14 Feb 2024 06:05:38 +0000 In-Reply-To: <20240214060538.3524462-1-kinseyho@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240214060538.3524462-1-kinseyho@google.com> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog Message-ID: <20240214060538.3524462-6-kinseyho@google.com> Subject: [PATCH mm-unstable v1 5/5] mm/mglru: improve swappiness handling From: Kinsey Ho To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yu Zhao , Donet Tom , "Aneesh Kumar K . V" , Kinsey Ho X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790853498405810725 X-GMAIL-MSGID: 1790853498405810725 The reclaimable number of anon pages used to set initial reclaim priority is only based on get_swappiness(). Use can_reclaim_anon_pages() to include NUMA node demotion. Also move the swappiness handling of when !__GFP_IO in try_to_shrink_lruvec() into isolate_folios(). Signed-off-by: Kinsey Ho --- mm/vmscan.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index f1019afa7813..0daf932feb86 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -4307,7 +4307,7 @@ static bool isolate_folio(struct lruvec *lruvec, struct folio *folio, struct sca { bool success; - /* swapping inhibited */ + /* swap constrained */ if (!(sc->gfp_mask & __GFP_IO) && (folio_test_dirty(folio) || (folio_test_anon(folio) && !folio_test_swapcache(folio)))) @@ -4476,9 +4476,11 @@ static int isolate_folios(struct lruvec *lruvec, struct scan_control *sc, int sw DEFINE_MIN_SEQ(lruvec); /* - * Try to make the obvious choice first. When anon and file are both - * available from the same generation, interpret swappiness 1 as file - * first and MAX_SWAPPINESS as anon first. + * Try to make the obvious choice first, and if anon and file are both + * available from the same generation, + * 1. Interpret swappiness 1 as file first and MAX_SWAPPINESS as anon first. + * 2. If !__GFP_IO, file first since clean pagecache is more likely to + * exist than clean swapcache. */ if (!swappiness) type = LRU_GEN_FILE; @@ -4488,6 +4490,8 @@ static int isolate_folios(struct lruvec *lruvec, struct scan_control *sc, int sw type = LRU_GEN_FILE; else if (swappiness == MAX_SWAPPINESS) type = LRU_GEN_ANON; + else if (!(sc->gfp_mask & __GFP_IO)) + type = LRU_GEN_FILE; else type = get_type_to_scan(lruvec, swappiness, &tier); @@ -4731,10 +4735,6 @@ static bool try_to_shrink_lruvec(struct lruvec *lruvec, struct scan_control *sc) unsigned long scanned = 0; int swappiness = get_swappiness(lruvec, sc); - /* clean file folios are more likely to exist */ - if (swappiness && !(sc->gfp_mask & __GFP_IO)) - swappiness = 1; - while (true) { int delta; @@ -4897,7 +4897,6 @@ static void set_initial_priority(struct pglist_data *pgdat, struct scan_control { int priority; unsigned long reclaimable; - struct lruvec *lruvec = mem_cgroup_lruvec(NULL, pgdat); if (sc->priority != DEF_PRIORITY || sc->nr_to_reclaim < MIN_LRU_BATCH) return; @@ -4907,7 +4906,7 @@ static void set_initial_priority(struct pglist_data *pgdat, struct scan_control * where reclaimed_to_scanned_ratio = inactive / total. */ reclaimable = node_page_state(pgdat, NR_INACTIVE_FILE); - if (get_swappiness(lruvec, sc)) + if (can_reclaim_anon_pages(NULL, pgdat->node_id, sc)) reclaimable += node_page_state(pgdat, NR_INACTIVE_ANON); /* round down reclaimable and round up sc->nr_to_reclaim */