From patchwork Fri Jan 26 15:25:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Levi Yun X-Patchwork-Id: 192657 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:106:343:edcb with SMTP id ju23csp8426dyc; Fri, 26 Jan 2024 07:27:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IEuSh3t1VMVj2u+BN1M9+94UUTvsqsoalN8zkxahMD9zAmq0L7BKpt9FqpN+6GDygpMcP5S X-Received: by 2002:a05:620a:4051:b0:781:ce9f:b3cf with SMTP id i17-20020a05620a405100b00781ce9fb3cfmr2022120qko.65.1706282832985; Fri, 26 Jan 2024 07:27:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706282832; cv=pass; d=google.com; s=arc-20160816; b=VgiHLB/CfZRBOBujyxLhF2Kvt6EsXD8Dcj+TW0YANgqr/TgHSEOJ72efIxg9XwF6sx hB0wVg35wt4JiZiqIHq/HixlKS56l2gBHsmxFRTtTvevI5Io+ppL+h8zq0iUoHSWoRif qglur45VgEY2ITiQAXkwOyM060t8WNwqSK4U5m2H79NN7O7sPHicO2ixChwvKj3pr7Uq yD4Jij0u/1fMITjPtPRhXTyM62zh5W2CoHESlg3SI72FTKFX9lJEWK48DLe4hz+Mykn1 Ts7GGg7xUeMCtcG63FVzEHXGOPZxIProRQVB+YJuEJWhL3DPz+Koz8bqpKYZrCL8XKkK ELuw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=d7qX8odXPP3RV5R94dRW7ALCQ1ih+UkRr3f07aHV/1A=; fh=b+JCvYEIx6spKxeMTGNuLO2RRsZxF1Q8wWXhCYVnyhQ=; b=tPQ9qJcsUuyMwBSRdphq/oNbrZLaFNxddG6sqUjA1EXarkbq/RRM1Y3m7Keq+C3ywP cC7WM8qtcXdYjtbdCz+IbtKiqZ0RmGuvg8hMJIEUuAnZR+IusNpypYr2ACQVgUrHmYnZ tl6TQYcbw5Sb7JHYWm0y3wwOCl3sQe9iAEzB8MG73JkwgQSf2pRZVV83U/p8WxHS6dur ViuaLdsTkPMhpJNpJ1ugoA9TRIT+SJm4KNlW7qhq5XxdsEXo4T6YXt4tJlyg0sCiF11T k6WTMjMuYHyfMRr3+u9qfA7GgNO0dlou6QqhR9qJX1Sq/VHRAcyltk0JOKF2enQ+8GAj VjyA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="kb9/bTBx"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-40276-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40276-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id bk26-20020a05620a1a1a00b007812e5a9151si1656389qkb.549.2024.01.26.07.27.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 07:27:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-40276-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="kb9/bTBx"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-40276-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40276-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 88AF91C2102D for ; Fri, 26 Jan 2024 15:27:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 542281D52D; Fri, 26 Jan 2024 15:26:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kb9/bTBx" Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (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 4DE931EA71 for ; Fri, 26 Jan 2024 15:26:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706282766; cv=none; b=scMpos41myJxWOT6+w5us4U1E69Uou8QfBBDUKSs/A+A8pClCZ4G2jKGjUCXJy07IVOn99cl9YQuffQ4M/WcFrOX8eLvYetUdjCbm1BmKlLMP4HUtpm1i0mE7htOcqxjmcUkIab7FruYdeZT8x84FRAfq54IrCKjCfME0sHZ2n4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706282766; c=relaxed/simple; bh=BRhWTo+/NPWNxQJuyEqZDTWB1pcTfonuimTvflg1itU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=jam5j29kEzpvu1W2+9/wmN2ifGrNRBZX2xJg6rbITP1GUak5Mn0MrRq2FdK4QOzxJ0SqvW6t/ICSfHk0WU6jzHpNOqAYLnvDVwtsF+JY8ktpGWB4L9Z2yYBfJuvTVa0lBtzonKrJqp9ZZGSleITJUrDzZpWgx2zMInT0tGQzwds= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kb9/bTBx; arc=none smtp.client-ip=209.85.221.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-3394dc2ae23so734621f8f.2 for ; Fri, 26 Jan 2024 07:26:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706282762; x=1706887562; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=d7qX8odXPP3RV5R94dRW7ALCQ1ih+UkRr3f07aHV/1A=; b=kb9/bTBxLYZgcsMhxkW+GNNxUyo5T1By7UH9gd2VW6GmWz8J0poEW2sSeXJo2mK9LU gJecFM2fNJQ32BeJGZta976IFCACusHJkEfRJfHLz4UjTOU893ZAC+z3uHD3Du6fAMcx s9bqJHs7Lqy/967ZU7g0oA43DzJN7vhjZNkh/I/zZwXEIh0rz6KlIuPjcExxqua/U5z0 wJHpFw6+RAiAL67yBXi7oDrHR2gElOY1mn0udMsbxUBw3y2v15B5TvCL1JAxPeabR85n MzHP052UUCUM5kU0BjvV7wSYb4JB11Pu6LxVsw2qykBUYmBiQg2OiI/GuyNnkbwjiP0n sH1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706282762; x=1706887562; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=d7qX8odXPP3RV5R94dRW7ALCQ1ih+UkRr3f07aHV/1A=; b=Chqz4UAVWlA+uWl8Pu3LomnM/3ddjq7xYBXjoycU10a4rJwDhJO1PdZufuMRn4rwRE zOzJd0k4lVm41mEyyHK68SH/aWl+16Kb1wOsR9vUpN4VbjARIlvs5S9/3Z1fJcaV5Tki yRh/oz/8JsUoYWZ+rx1yB/wG22vKZPvt1JAty/raov7afh+C1MxWFFGpq6fDqrBjdkOU 2dJ8rxz1TKHodLTOYRuD3MvUnTdnbZaZbDvqKQivmTyZT5B+Al7hOT0tetmUnkz8nrR+ eTHQ3eo48FqJYm6J+ScNo+JjB2a+i2XBr3U3D9feWskVKzeNwW6ikWAkPmbRyQl2eS3Q xUSA== X-Gm-Message-State: AOJu0YwVy4NPWw61lkvMPFO+Z0KkfT5htz42QTEF1WDVJqnjssVpvOGN XeHqcwo6wX+jxHhfQedSxDB74rL1BpYol7dhc9z9xx13OKZGhyx+ X-Received: by 2002:adf:ce09:0:b0:337:cf68:c06 with SMTP id p9-20020adfce09000000b00337cf680c06mr791836wrn.77.1706282762096; Fri, 26 Jan 2024 07:26:02 -0800 (PST) Received: from localhost.localdomain ([212.187.182.162]) by smtp.gmail.com with ESMTPSA id r14-20020a5d498e000000b003392bbeeed3sm1477098wrq.47.2024.01.26.07.26.01 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 26 Jan 2024 07:26:01 -0800 (PST) From: Levi Yun To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Levi Yun Subject: [PATCH] kswapd: Replace try_to_freeze to kthread_freezable_should_stop. Date: Fri, 26 Jan 2024 15:25:54 +0000 Message-ID: <20240126152556.58791-1-ppbuk5246@gmail.com> X-Mailer: git-send-email 2.41.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789167228011287792 X-GMAIL-MSGID: 1789167228011287792 Instead of using try_to_freeze, use kthread_freezable_should_stop in kswapd. By this, we can avoid unnecessary freezing when kswapd should stop. Signed-off-by: Levi Yun --- mm/vmscan.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) -- 2.39.2 diff --git a/mm/vmscan.c b/mm/vmscan.c index 4f9c854ce6cc..1f139830b26f 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -6796,6 +6796,7 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int highest_zoneidx) bool raise_priority = true; bool balanced; bool ret; + bool was_frozen; sc.reclaim_idx = highest_zoneidx; @@ -6894,9 +6895,9 @@ static int balance_pgdat(pg_data_t *pgdat, int order, int highest_zoneidx) /* Check if kswapd should be suspending */ __fs_reclaim_release(_THIS_IP_); - ret = try_to_freeze(); + ret = kthread_freezable_should_stop(&was_frozen); __fs_reclaim_acquire(_THIS_IP_); - if (ret || kthread_should_stop()) + if (was_frozen || ret) break; /* @@ -7102,7 +7103,7 @@ static int kswapd(void *p) WRITE_ONCE(pgdat->kswapd_highest_zoneidx, MAX_NR_ZONES); atomic_set(&pgdat->nr_writeback_throttled, 0); for ( ; ; ) { - bool ret; + bool was_frozen; alloc_order = reclaim_order = READ_ONCE(pgdat->kswapd_order); highest_zoneidx = kswapd_highest_zoneidx(pgdat, @@ -7119,15 +7120,14 @@ static int kswapd(void *p) WRITE_ONCE(pgdat->kswapd_order, 0); WRITE_ONCE(pgdat->kswapd_highest_zoneidx, MAX_NR_ZONES); - ret = try_to_freeze(); - if (kthread_should_stop()) + if (kthread_freezable_should_stop(&was_frozen)) break; /* * We can speed up thawing tasks if we don't call balance_pgdat * after returning from the refrigerator */ - if (ret) + if (was_frozen) continue; /*