From patchwork Tue Nov 23 17:46:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shakeel Butt X-Patchwork-Id: 12634933 Return-Path: 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 62608C433EF for ; Tue, 23 Nov 2021 17:47:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C36C36B006C; Tue, 23 Nov 2021 12:47:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BE5EF6B0071; Tue, 23 Nov 2021 12:47:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A87396B0075; Tue, 23 Nov 2021 12:47:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0009.hostedemail.com [216.40.44.9]) by kanga.kvack.org (Postfix) with ESMTP id 9A6536B006C for ; Tue, 23 Nov 2021 12:47:13 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 5C47380C5ECC for ; Tue, 23 Nov 2021 17:47:03 +0000 (UTC) X-FDA: 78840926010.01.EA66E8B Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) by imf05.hostedemail.com (Postfix) with ESMTP id 8E2F4508BB88 for ; Tue, 23 Nov 2021 17:46:57 +0000 (UTC) Received: by mail-pf1-f201.google.com with SMTP id x9-20020a056a00188900b0049fd22b9a27so12146193pfh.18 for ; Tue, 23 Nov 2021 09:47:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=087vQaZWUKxRpGonVzwMVh0M7VkYLkSnxisBZd5obmA=; b=tCDZYtDjA+pqhy7EApb9w2YUe6thqQz8V9NYf8eIZXyF6AeYq3rWG2LRFBcFCsTQiR kneeeh4myslIyFGROJFluwIntriat5jZ2FTqFTKKTlC8BO0VCZNEJpFrT2d53G6fcq+M CFklWxtwSQMwS6ZAhddWeOpW2iPsP/u1yWs1Q5UONrn9RlxZUZIkrvEGpKphszkdUjYQ JLCbL7JC2OII02WEOG9fo1MHmtHnCCJ5m9CdTEQwUtBwS5Kc6UpXOegyHFKzKmSCWg0X pLVpqN70jYM1mpkkFeUMNNtHejmGKZpcPl2IymdGZy5hQ0PAMOi6+3knDRJAmsNYP6wE GSPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=087vQaZWUKxRpGonVzwMVh0M7VkYLkSnxisBZd5obmA=; b=nylr/wtxG8SoAXTAzOtt0Wezl9xVuwt6laO6dBKfSyzWm2z+YUmb/52QFVfBU10fBQ GJCgNWCHjh1VuyDGkmVe2xwJTjd1nNye3FdmBHPJLFRQyRG3S5Xxyu2+oaCJ59h6F6St hOz6tUxbc294SS3fjvtnsq6j1FE5JSHBhH/XxN0x/l2DtC7VU/69Ft8LCC27OheHWkD7 iU2gOEoGAftPWgJ1H2iPHueMkcklqGpbeJyCylEnCjW2LgUDeX1x4ULyGAXSpX+51VWc ZMM+H/sHxvUgWMs/GewAppBrLDO7jUCrMA57RwZyujnCkGTj58wKIMnpk4aIg1nIJ3S7 mTFQ== X-Gm-Message-State: AOAM532vi9ZZnqImosV3OvxK8g2FJVnGdl1Hv1X6Fw7Nb8uz64xbV9Oo 4oM8sJs71/WqW/qN41aik2SDhHKpX157fw== X-Google-Smtp-Source: ABdhPJwwKdrF+f/Ep44GPc4Dd3kMsoZXb+lKE1IEUG8p4nTJN1mOX8PuRqG+EzEyn8M5gOBj3prjDolC99pwHA== X-Received: from shakeelb.svl.corp.google.com ([2620:15c:2cd:202:bda6:1a8e:6bfd:ec0c]) (user=shakeelb job=sendgmr) by 2002:a17:90b:1812:: with SMTP id lw18mr5227173pjb.196.1637689621682; Tue, 23 Nov 2021 09:47:01 -0800 (PST) Date: Tue, 23 Nov 2021 09:46:58 -0800 Message-Id: <20211123174658.1728753-1-shakeelb@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.34.0.rc2.393.gf8c9666880-goog Subject: [PATCH] mm: thp: update split_queue_len correctly From: Shakeel Butt To: David Hildenbrand , "Kirill A . Shutemov" , Yang Shi , Zi Yan , Matthew Wilcox Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Shakeel Butt X-Stat-Signature: ic7j1rq84ofxxgz6f4o8puzop9x5i9e3 Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=tCDZYtDj; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf05.hostedemail.com: domain of 3FSmdYQgKCO4iXQaUUbRWeeWbU.SecbYdkn-ccalQSa.ehW@flex--shakeelb.bounces.google.com designates 209.85.210.201 as permitted sender) smtp.mailfrom=3FSmdYQgKCO4iXQaUUbRWeeWbU.SecbYdkn-ccalQSa.ehW@flex--shakeelb.bounces.google.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 8E2F4508BB88 X-HE-Tag: 1637689617-784509 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The deferred THPs are split on memory pressure through shrinker callback and splitting of THP during reclaim can fail for several reasons like unable to lock the THP, under writeback or unexpected number of pins on the THP. Such pages are put back on the deferred split list for consideration later. However kernel does not update the deferred queue size on putting back the pages whose split was failed. This patch fixes that. Fixes: 364c1eebe453 ("mm: thp: extract split_queue_* into a struct") Signed-off-by: Shakeel Butt --- mm/huge_memory.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index e5483347291c..4fff9584815b 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2809,7 +2809,7 @@ static unsigned long deferred_split_scan(struct shrinker *shrink, unsigned long flags; LIST_HEAD(list), *pos, *next; struct page *page; - int split = 0; + unsigned long split = 0, num = 0; #ifdef CONFIG_MEMCG if (sc->memcg) @@ -2823,6 +2823,7 @@ static unsigned long deferred_split_scan(struct shrinker *shrink, page = compound_head(page); if (get_page_unless_zero(page)) { list_move(page_deferred_list(page), &list); + num++; } else { /* We lost race with put_compound_page() */ list_del_init(page_deferred_list(page)); @@ -2847,6 +2848,7 @@ static unsigned long deferred_split_scan(struct shrinker *shrink, spin_lock_irqsave(&ds_queue->split_queue_lock, flags); list_splice_tail(&list, &ds_queue->split_queue); + ds_queue->split_queue_len += (num - split); spin_unlock_irqrestore(&ds_queue->split_queue_lock, flags); /*