From patchwork Fri Feb 12 17:33:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charan Teja Kalla X-Patchwork-Id: 12085747 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8519C433DB for ; Fri, 12 Feb 2021 17:33:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 17EC364E8A for ; Fri, 12 Feb 2021 17:33:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 17EC364E8A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6C23D8D0076; Fri, 12 Feb 2021 12:33:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 673DD8D0060; Fri, 12 Feb 2021 12:33:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 564348D0076; Fri, 12 Feb 2021 12:33:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0204.hostedemail.com [216.40.44.204]) by kanga.kvack.org (Postfix) with ESMTP id 404728D0060 for ; Fri, 12 Feb 2021 12:33:34 -0500 (EST) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 0899218037D4D for ; Fri, 12 Feb 2021 17:33:34 +0000 (UTC) X-FDA: 77810312748.13.E992060 Received: from mail29.static.mailgun.info (mail29.static.mailgun.info [104.130.122.29]) by imf05.hostedemail.com (Postfix) with ESMTP id 3C868E0001AF for ; Fri, 12 Feb 2021 17:33:31 +0000 (UTC) DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1613151213; h=Message-Id: Date: Subject: Cc: To: From: Sender; bh=K2S35ZMNfNKZ70ztSuai8wLbHzfvfWAbdZyFwSz4e3Q=; b=uDz99cWQ/c1ZRR/2kR/mTjr+PmWMkAvJNTB77PMrZNL4Qj5BEjTIbwfCvbbLGgNET9PtP5tV 56uClGjB8q3dwqn3WqLXGIpnSwiegHld8oyuD6vvo9+wMA010mBmXSvEJbEULvcE6TczasvZ UoboHFT6E0hLGHQ7/IVKcgiDdVY= X-Mailgun-Sending-Ip: 104.130.122.29 X-Mailgun-Sid: WyIwY2Q3OCIsICJsaW51eC1tbUBrdmFjay5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n06.prod.us-east-1.postgun.com with SMTP id 6026bbeae3df861f4b21a435 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Fri, 12 Feb 2021 17:33:30 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id A0629C433C6; Fri, 12 Feb 2021 17:33:29 +0000 (UTC) Received: from charante-linux.qualcomm.com (unknown [202.46.22.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: charante) by smtp.codeaurora.org (Postfix) with ESMTPSA id 82B37C433CA; Fri, 12 Feb 2021 17:33:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 82B37C433CA Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=charante@codeaurora.org From: Charan Teja Reddy To: akpm@linux-foundation.org, rientjes@google.com, vbabka@suse.cz, linux-mm@kvack.org Cc: vinmenon@codeaurora.org, linux-kernel@vger.kernel.org, Charan Teja Reddy Subject: [PATCH V2] mm: compaction: update the COMPACT[STALL|FAIL] events properly Date: Fri, 12 Feb 2021 23:03:04 +0530 Message-Id: <1613151184-21213-1-git-send-email-charante@codeaurora.org> X-Mailer: git-send-email 2.7.4 X-Stat-Signature: mw1h5aktc8d7j51zzetdom31yg7tf76e X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 3C868E0001AF Received-SPF: none (mg.codeaurora.org>: No applicable sender policy available) receiver=imf05; identity=mailfrom; envelope-from=""; helo=mail29.static.mailgun.info; client-ip=104.130.122.29 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1613151211-812878 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: By definition, COMPACT[STALL|FAIL] events needs to be counted when there is 'At least in one zone compaction wasn't deferred or skipped from the direct compaction'. And when compaction is skipped or deferred, COMPACT_SKIPPED will be returned but it will still go and update these compaction events which is wrong in the sense that COMPACT[STALL|FAIL] is counted without even trying the compaction. Correct this by skipping the counting of these events when COMPACT_SKIPPED is returned for compaction. This indirectly also avoid the unnecessary try into the get_page_from_freelist() when compaction is not even tried. There is a corner case where compaction is skipped but still count COMPACTSTALL event, which is that IRQ came and freed the page and the same is captured in capture_control. Signed-off-by: Charan Teja Reddy Acked-by: Vlastimil Babka Acked-by: David Rientjes --- changes in V1: https://lore.kernel.org/patchwork/patch/1373665/ mm/compaction.c | 8 ++++++++ mm/page_alloc.c | 2 ++ 2 files changed, 10 insertions(+) diff --git a/mm/compaction.c b/mm/compaction.c index 190ccda..104ebef 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -2487,6 +2487,14 @@ static enum compact_result compact_zone_order(struct zone *zone, int order, */ WRITE_ONCE(current->capture_control, NULL); *capture = READ_ONCE(capc.page); + /* + * Technically, it is also possible that compaction is skipped but + * the page is still captured out of luck(IRQ came and freed the page). + * Returning COMPACT_SUCCESS in such cases helps in properly accounting + * the COMPACT[STALL|FAIL] when compaction is skipped. + */ + if (*capture) + ret = COMPACT_SUCCESS; return ret; } diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 519a60d..531f244 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4152,6 +4152,8 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order, memalloc_noreclaim_restore(noreclaim_flag); psi_memstall_leave(&pflags); + if (*compact_result == COMPACT_SKIPPED) + return NULL; /* * At least in one zone compaction wasn't deferred or skipped, so let's * count a compaction stall