Message ID | 20240711191957.939105-1-yuzhao@google.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F566C3DA45 for <linux-mm@archiver.kernel.org>; Thu, 11 Jul 2024 19:20:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 253B96B009A; Thu, 11 Jul 2024 15:20:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 204356B009B; Thu, 11 Jul 2024 15:20:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0F43F6B009C; Thu, 11 Jul 2024 15:20:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id E4E566B009A for <linux-mm@kvack.org>; Thu, 11 Jul 2024 15:20:03 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id A1F7E1A0364 for <linux-mm@kvack.org>; Thu, 11 Jul 2024 19:20:03 +0000 (UTC) X-FDA: 82328437086.17.E30603E Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf05.hostedemail.com (Postfix) with ESMTP id F2010100027 for <linux-mm@kvack.org>; Thu, 11 Jul 2024 19:20:01 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=KysMvxKM; spf=pass (imf05.hostedemail.com: domain of 3YDCQZgYKCD0xtygZnfnnfkd.bnlkhmtw-lljuZbj.nqf@flex--yuzhao.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3YDCQZgYKCD0xtygZnfnnfkd.bnlkhmtw-lljuZbj.nqf@flex--yuzhao.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1720725576; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=Y0IJBxGEZh8aIDvEw0KmFnuORNT4a0CNIuPo7E0B6UQ=; b=v6ajfh8jIsZxa5jjfujGbEECxoUaRkzRd7IoCW34iRI4U1eqjUX0h726jA81g+YnsV4lgG Ab+luPHXCzFAP3Bay//33g8cUGW5MCZHJIQWiN67H2P0//V3Xwm2EJftIgnsoz1VIod3hQ WhdN21c5G4P1ibErUEFg7dZhHMX0yEY= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=KysMvxKM; spf=pass (imf05.hostedemail.com: domain of 3YDCQZgYKCD0xtygZnfnnfkd.bnlkhmtw-lljuZbj.nqf@flex--yuzhao.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3YDCQZgYKCD0xtygZnfnnfkd.bnlkhmtw-lljuZbj.nqf@flex--yuzhao.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720725576; a=rsa-sha256; cv=none; b=A2sexKBXjHVsNv5dyLGvTK0wed8preHRWfKKMeHs65RJiyAcWAX3QcEWhWhVu+qyU+s4mb GKyQsPwn17tcgz5WBul3/jn+xqyhBJA/kIHnQC37j9DXz58bTV1mvDzusWDs3EEGhYv0zY YjdyIjmFw4Gl/K92JlkzYHbkSiFvoAw= Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e03a7949504so2057821276.2 for <linux-mm@kvack.org>; Thu, 11 Jul 2024 12:20:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720725601; x=1721330401; darn=kvack.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=Y0IJBxGEZh8aIDvEw0KmFnuORNT4a0CNIuPo7E0B6UQ=; b=KysMvxKMW0Wf1pyPljjcuwf02TAyKSu5lY0x5hp2cOM8dpbw2hgc98IvUKnpZefZpl LCCORUGqR0RPGmjiDMqKD2YDUpxN//DyZvmg6ruUwkV+i5MLIBSrVTJIxH4UF74aYG5M 8h7hifxPEfV4f8d/DtoYNu2M8Ik2V8buw4x4OYafia1sUGwSniYLj4I4Bit+CCF0hSLS nvGEtQqr1sTthQ+0v1q8NjOHzZHNfiYumJrMzaHoeBV0AYo7Hug+9vzlagj1L7GK8hfc 31AZvERqMppUiWAfyV4RUcmc6ztOnjlP3ZDYE27JLS0wKGNNl8Irjr1bp2gLnBhzZsNt 0w+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720725601; x=1721330401; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Y0IJBxGEZh8aIDvEw0KmFnuORNT4a0CNIuPo7E0B6UQ=; b=UiU5Zp5dtSiQnroPcuhvdPOED87cCd5XY5g3OTySFWATeP33thuaOEOthMU1nG4JN/ tRenoDFkShafVCrLtA3wsKOFk4FHBT/gYvJI3mAsj3XJFuFK1U7fcNK9ihEGPZNRB+Xt xywENACm5cL4dmLbuI62z5ItD/1zfjyJaVpQ0/tZmzjsuXRl/AxhzIH5W08XywSi9w+l nGISQ1rfe0ZCADrjQQ8jkzw/4yCmv3ddXO9QZX8/pUwXGpDYusR5bc+g28p0IqzohpZ2 DSO+0v0NifWS96yDifYiXHlMRO3fQecxDvWP/yBBPcRj7jSnUeFVzTZqIVFNctklf3F1 TA/g== X-Gm-Message-State: AOJu0Yy0T7L9OkB/vrHkPzTJLim+i2Pb0TgXA8d57HUm9h5OvKU5Rnn6 vanXFk08xeYCofc2C3aZyOORKSwrS2Ktpmku03OVIufhYq4lKiTm8ybvdUlGPiB0Z++mJV8mpr4 KKA== X-Google-Smtp-Source: AGHT+IFl5/lwjZcmg0Gramun5B417BFKYSxf44G9wfJyYgQTaJof76xuc6ZiaGwXX8SHDS26hFf2arMicVw= X-Received: from yuzhao2.bld.corp.google.com ([2a00:79e0:2e28:6:7f87:3390:5055:fce9]) (user=yuzhao job=sendgmr) by 2002:a05:6902:2b0d:b0:e03:589b:cbe1 with SMTP id 3f1490d57ef6-e041b070dfbmr748760276.7.1720725600922; Thu, 11 Jul 2024 12:20:00 -0700 (PDT) Date: Thu, 11 Jul 2024 13:19:56 -0600 Mime-Version: 1.0 X-Mailer: git-send-email 2.45.2.993.g49e7a77208-goog Message-ID: <20240711191957.939105-1-yuzhao@google.com> Subject: [PATCH mm-unstable v1 1/2] mm/mglru: fix div-by-zero in vmpressure_calc_level() From: Yu Zhao <yuzhao@google.com> To: Andrew Morton <akpm@linux-foundation.org> Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yu Zhao <yuzhao@google.com>, Wei Xu <weixugc@google.com>, stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Stat-Signature: y9qj1ofjri4j7gqkq783s9gogpm8hhjh X-Rspam-User: X-Rspamd-Queue-Id: F2010100027 X-Rspamd-Server: rspam02 X-HE-Tag: 1720725601-176113 X-HE-Meta: U2FsdGVkX19pHwjAloAT/xwdoIeP8zXJPWe/HFFiXcym9lQNOkJ7HU0bRu7YPdrl2EsU28bF369V1pEBx+TMpv7CLfqyN3FqKPdDQMIgVuBYTICwke6ShMu932tLijXmEslELJ8S7Sk92ynraMTcovfs8nbat1t5P078AnG7etdjmmyRkYWE9dmmBj/JBCuMN7WxD9zYdh3KYbaM05uX5H5v+WOec++FWqXaA4N4cBgHeiqzGTOmacb4fnVGswsDj7gPruckniC7yRKA5Y33qD7o13uOl5hQY7iJGmCNehXdsN0hsYMUgoEt5Hr3C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/KPd355lnTk6tGhXjMORBK+YAGfYfun1JaG8gDd2ar8Sqn+AMhu73pSvS6y4Crsa8X3MuHH4YcRZ1FsrYQsc/Z1mSaV1XL4qeep8hMRbY4pIUjviCOB7G62/8kwzV7uO/kVUj7BbjPZKywiOzsv63SpJMedmSGqXZ3z7YHWE8N6hGMB6AHP6ZoL/AtiVTt3+SErMQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.001464, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
[mm-unstable,v1,1/2] mm/mglru: fix div-by-zero in vmpressure_calc_level()
|
expand
|
diff --git a/mm/vmscan.c b/mm/vmscan.c index 0761f91b407f..6403038c776e 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -4597,7 +4597,6 @@ static int evict_folios(struct lruvec *lruvec, struct scan_control *sc, int swap /* retry folios that may have missed folio_rotate_reclaimable() */ list_move(&folio->lru, &clean); - sc->nr_scanned -= folio_nr_pages(folio); } spin_lock_irq(&lruvec->lru_lock);
evict_folios() uses a second pass to reclaim folios that have gone through page writeback and become clean before it finishes the first pass, since folio_rotate_reclaimable() cannot handle those folios due to the isolation. The second pass tries to avoid potential double counting by deducting scan_control->nr_scanned. However, this can result in underflow of nr_scanned, under a condition where shrink_folio_list() does not increment nr_scanned, i.e., when folio_trylock() fails. The underflow can cause the divisor, i.e., scale=scanned+reclaimed in vmpressure_calc_level(), to become zero, resulting in the following crash: [exception RIP: vmpressure_work_fn+101] process_one_work at ffffffffa3313f2b Since scan_control->nr_scanned has no established semantics, the potential double counting has minimal risks. Therefore, fix the problem by not deducting scan_control->nr_scanned in evict_folios(). Reported-by: Wei Xu <weixugc@google.com> Fixes: 359a5e1416ca ("mm: multi-gen LRU: retry folios written back while isolated") Cc: stable@vger.kernel.org Signed-off-by: Yu Zhao <yuzhao@google.com> --- mm/vmscan.c | 1 - 1 file changed, 1 deletion(-)