From mboxrd@z Thu Jan 1 00:00:00 1970 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 C4416C433EF for ; Tue, 23 Nov 2021 19:03:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 502346B0072; Tue, 23 Nov 2021 14:03:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4B16B6B0074; Tue, 23 Nov 2021 14:03:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3A2F86B0075; Tue, 23 Nov 2021 14:03:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0048.hostedemail.com [216.40.44.48]) by kanga.kvack.org (Postfix) with ESMTP id 2D3C06B0072 for ; Tue, 23 Nov 2021 14:03:41 -0500 (EST) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id F321680E7ABA for ; Tue, 23 Nov 2021 19:03:30 +0000 (UTC) X-FDA: 78841118622.13.20A6767 Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) by imf15.hostedemail.com (Postfix) with ESMTP id 2FC4CD000096 for ; Tue, 23 Nov 2021 19:03:26 +0000 (UTC) Received: by mail-lj1-f169.google.com with SMTP id k2so201218lji.4 for ; Tue, 23 Nov 2021 11:03:30 -0800 (PST) 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=EjOmAhFDgrhvowToE/lUbuq/OCLfMw8Xrzh45UKZoyQ=; b=IfDn/GrTpnwDujtS5SsdHh/LSaxaw3XLTTp9JDQ2OHIftjSS5OUthFU8hod2rbOcP9 cLN/U3HF+SI/4VezCS3aqAOSUY6ZcEGO/aU74DTx3/rGWoNmfgKBAyOwcM1Op1k+b9Gs gOmzBr2P9aF5EdSQGLp4gfdEDYjd95qjK4fZHFRKKdiAmwqo/PUipXDbvfCkEjaJzBK5 OLoMgMbhVd6lYdqG0DdoJOld+f04kB/tzJ6uUzqMfsINVi3VnnIdsBHwKpJBqqsXiB3T puMJTv6pq+lIhYAR2fDXmPgCSD73cLUYYJsmSxhMlnp5H4E2GW7gmFG4CKveohy8Hxkj GcRQ== 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=EjOmAhFDgrhvowToE/lUbuq/OCLfMw8Xrzh45UKZoyQ=; b=2vuLjPo2XFTIJGXCKeB5keAGmQfyh0YRQDa7VwjAQWtdMyN3joQiN2Cqp2UrQSYh2B NII6BcS1/mnkfpz0FyrFw07Wjf8xuniwHYzcAFgxCDXGvdtQlS9tLNAxnFvGLFGq/Oh7 6PUG5idX9SRjhrp7azVywXMnUi9Dmr9xnzNLX8XGCu+EA2GhFtM+S3YvpTvkmU3C0LE6 I8VIeI8x6nM6V3qjvgysddJXKNc2r1xmaV5KyUwvmLLJ1pD1Y6X3U4ARnBzw5PCAHhmf 2eVM1gAYOPlguKZRHCSSSP06vwTrXaeAr7s3NgkvgcKOuvx/juGFGHZlCjz58O+O+zL7 FMGg== X-Gm-Message-State: AOAM532PpnSQEp5LyoDa8cMkqtRefxWBGqRbeqbNp83N5oc2SnhEdplG 66cm8vF6FLluMfwl+4egXbmvFbSbmVXKzoRdvT1+0g== X-Google-Smtp-Source: ABdhPJyiAR2C563ifXIiqy/wu450DL8dnjn2qI8PRNrqU7Cc8chD+JxOfnmZPNzhpTj/uicXOAyMcBnu96g2DqL+gpY= X-Received: by 2002:a2e:a314:: with SMTP id l20mr8319445lje.86.1637694208612; Tue, 23 Nov 2021 11:03:28 -0800 (PST) MIME-Version: 1.0 References: <20211123174658.1728753-1-shakeelb@google.com> In-Reply-To: From: Shakeel Butt Date: Tue, 23 Nov 2021 11:03:17 -0800 Message-ID: Subject: Re: [PATCH] mm: thp: update split_queue_len correctly To: Yang Shi Cc: David Hildenbrand , "Kirill A . Shutemov" , Zi Yan , Matthew Wilcox , Andrew Morton , Linux MM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" X-Stat-Signature: 578s4378ozj64h6psptpntrqw8uqtrta X-Rspamd-Queue-Id: 2FC4CD000096 X-Rspamd-Server: rspam07 Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="IfDn/GrT"; spf=pass (imf15.hostedemail.com: domain of shakeelb@google.com designates 209.85.208.169 as permitted sender) smtp.mailfrom=shakeelb@google.com; dmarc=pass (policy=reject) header.from=google.com X-HE-Tag: 1637694206-749281 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: On Tue, Nov 23, 2021 at 10:51 AM Yang Shi wrote: > > On Tue, Nov 23, 2021 at 9:47 AM Shakeel Butt wrote: > > > > 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++; > > Thanks for catching this. But I don't think "num" is needed, isn't the > below code good enough? Yes you are right. I will send the next version. I will at least change the type of split to unsigned long. > > diff --git a/mm/huge_memory.c b/mm/huge_memory.c > index e5483347291c..1fbd8299db0c 100644 > --- a/mm/huge_memory.c > +++ b/mm/huge_memory.c > @@ -2847,6 +2847,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 -= split; > spin_unlock_irqrestore(&ds_queue->split_queue_lock, flags); > > /* > > > } 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); > > > > /* > > -- > > 2.34.0.rc2.393.gf8c9666880-goog > >