From patchwork Wed Aug 19 04:27:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 11722497 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CF051138C for ; Wed, 19 Aug 2020 04:27:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8E8842083B for ; Wed, 19 Aug 2020 04:27:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="o+etTA4y" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8E8842083B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C8BBE8D0005; Wed, 19 Aug 2020 00:27:18 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BEE226B0036; Wed, 19 Aug 2020 00:27:18 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A8E778D0005; Wed, 19 Aug 2020 00:27:18 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 8D6266B0033 for ; Wed, 19 Aug 2020 00:27:18 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 4A47A181AEF09 for ; Wed, 19 Aug 2020 04:27:18 +0000 (UTC) X-FDA: 77166033756.21.suit78_5a177cb27025 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id 1A501180442C0 for ; Wed, 19 Aug 2020 04:27:18 +0000 (UTC) X-Spam-Summary: 1,0,0,e39efb698f9125f3,d41d8cd98f00b204,alexander.duyck@gmail.com,,RULES_HIT:41:69:152:273:355:379:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1431:1437:1515:1516:1518:1535:1544:1593:1594:1605:1711:1730:1747:1777:1792:2393:2559:2562:2693:2895:2901:3138:3139:3140:3141:3142:3865:3866:3867:3868:3870:3871:3872:3874:4118:4250:5007:6119:6120:6261:6653:6742:7576:7903:8660:8957:9413:9592:10004:11026:11232:11658:11914:12043:12296:12297:12438:12517:12519:12555:12679:12683:12760:13141:13148:13161:13229:13230:13255:14096:14097:14181:14687:14721:21063:21080:21444:21451:21627:21666:21740:21795:21939:21990:30012:30051:30054:30056:30070,0,RBL:209.85.160.195:@gmail.com:.lbl8.mailshell.net-62.50.0.100 66.100.201.100;04y8e9x89wh3mc8m9h56y8apycq7eycmixc4eomoooa89bwa3smu95tzcmxqxp7.ma3hsducyhdcin54thk6m31ka4zihkpk83qcapjg5y1x87ze8rpxnfyy5riwxw6.a-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL :neutral X-HE-Tag: suit78_5a177cb27025 X-Filterd-Recvd-Size: 7545 Received: from mail-qt1-f195.google.com (mail-qt1-f195.google.com [209.85.160.195]) by imf39.hostedemail.com (Postfix) with ESMTP for ; Wed, 19 Aug 2020 04:27:17 +0000 (UTC) Received: by mail-qt1-f195.google.com with SMTP id v22so16908971qtq.8 for ; Tue, 18 Aug 2020 21:27:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=nJQwZMk0HVg1Xi5MdVbpw2haA8xPFp0DOao/4ztkzvc=; b=o+etTA4y6IyxOSsiGgtDeP6nsslFfCsdsqI/ytWlD0PrEUbBiCogFNkpkPYaJS2uSV 5Jrtw6H7e8g3+b0ajpM/n1TB1IoHygoMchrjdnR0ctTVyV0u7c9ejlKYhU6tpaFAg8lf cxEjRIH6aarpICQ3D40Jep09AZ1RKdcrXs8Hqoqzr4SdDacFmBkgE/O0LUZAi6SWO5TI 6GtbeZRf+u/eU7YRn+F6n6QC9lvwgq7CpKoibwq4XfQwRL7JOtdwY79HY6VrXMs2V0Lm faOt3XiyhX3ezawcRskNnct6vHVkrJ6FnE5Eo4JnELvFe2nfcGZXW8LJgF6OIMBWdvfL d8wA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=nJQwZMk0HVg1Xi5MdVbpw2haA8xPFp0DOao/4ztkzvc=; b=CvB5NLTl7iYyOmtlH58ea5mIWp4SzFBKcRfQ/q7vgDiLOnwxA/Ilwadjs4rbulGpqe ut/xt9t7KbKAfEnN4BnIy824gOEZhTy2xBXvZr3SBu67KeyekGxM43+lqx79U4Vw1Jgv hGRk0ETSIHSgzJUaod9WfueTvWFourSfIRxtYEvteAf5LZbJ4b526CK3bHPN8fyPKDA0 UsBhi49BseLwb3C1LV4HnwpO3HQVi5MNKvW9i857RVel3AxlVwGquHPqIjy+HCftVLzK 2nGplK2C/KXYuWo1BPMx2TRkNkLqclJTn1dRyP90lkhWF8F6jg3EYMrXPCLFI++lgHhJ /xqQ== X-Gm-Message-State: AOAM530eAFoyOMKL7vTuhLFR6yGLQ9p5oCrCbSHB/YAfify2ebjHADOQ D3ttcl7vV6ehnTf05ropbtQ= X-Google-Smtp-Source: ABdhPJxoECmzGuSI1+0DQ9CGQygdSLOyI+slhpLtdVXP5IOP+KyGcOaAEGCSGUdabuqBc1XlA2TaKQ== X-Received: by 2002:aed:3e0c:: with SMTP id l12mr21600150qtf.179.1597811236964; Tue, 18 Aug 2020 21:27:16 -0700 (PDT) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id p33sm27941856qtp.49.2020.08.18.21.27.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Aug 2020 21:27:16 -0700 (PDT) Subject: [RFC PATCH v2 2/5] mm: Drop use of test_and_set_skip in favor of just setting skip From: Alexander Duyck To: alex.shi@linux.alibaba.com Cc: yang.shi@linux.alibaba.com, lkp@intel.com, rong.a.chen@intel.com, khlebnikov@yandex-team.ru, kirill@shutemov.name, hughd@google.com, linux-kernel@vger.kernel.org, alexander.duyck@gmail.com, daniel.m.jordan@oracle.com, linux-mm@kvack.org, shakeelb@google.com, willy@infradead.org, hannes@cmpxchg.org, tj@kernel.org, cgroups@vger.kernel.org, akpm@linux-foundation.org, richard.weiyang@gmail.com, mgorman@techsingularity.net, iamjoonsoo.kim@lge.com Date: Tue, 18 Aug 2020 21:27:14 -0700 Message-ID: <20200819042713.23414.5084.stgit@localhost.localdomain> In-Reply-To: <20200819041852.23414.95939.stgit@localhost.localdomain> References: <20200819041852.23414.95939.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Rspamd-Queue-Id: 1A501180442C0 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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: From: Alexander Duyck The only user of test_and_set_skip was isolate_migratepages_block and it was using it after a call that was testing and clearing the LRU flag. As such it really didn't need to be behind the LRU lock anymore as it wasn't really fulfilling its purpose. Since it is only possible to be able to test and set the skip flag if we were able to obtain the LRU bit for the first page in the pageblock the use of the test_and_set_skip becomes redundant as the LRU flag now becomes the item that limits us to only one thread being able to perform the operation and there being no need for a test_and_set operation. With that being the case we can simply drop the bit and instead directly just call the set_pageblock_skip function if the page we are working on is the valid_page at the start of the pageblock. Then any other threads that enter this pageblock should see the skip bit set on the first valid page in the pageblock. Since we have dropped the late abort case we can drop the code that was clearing the LRU flag and calling page_put since the abort case will now not be holding a reference to a page now. Signed-off-by: Alexander Duyck Reviewed-by: Alex Shi --- mm/compaction.c | 53 +++++++++++++---------------------------------------- 1 file changed, 13 insertions(+), 40 deletions(-) diff --git a/mm/compaction.c b/mm/compaction.c index 88c7b950f676..f986c67e83cc 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -399,29 +399,6 @@ void reset_isolation_suitable(pg_data_t *pgdat) } } -/* - * Sets the pageblock skip bit if it was clear. Note that this is a hint as - * locks are not required for read/writers. Returns true if it was already set. - */ -static bool test_and_set_skip(struct compact_control *cc, struct page *page, - unsigned long pfn) -{ - bool skip; - - /* Do no update if skip hint is being ignored */ - if (cc->ignore_skip_hint) - return false; - - if (!IS_ALIGNED(pfn, pageblock_nr_pages)) - return false; - - skip = get_pageblock_skip(page); - if (!skip && !cc->no_set_skip_hint) - set_pageblock_skip(page); - - return skip; -} - static void update_cached_migrate(struct compact_control *cc, unsigned long pfn) { struct zone *zone = cc->zone; @@ -480,12 +457,6 @@ static inline void update_pageblock_skip(struct compact_control *cc, static void update_cached_migrate(struct compact_control *cc, unsigned long pfn) { } - -static bool test_and_set_skip(struct compact_control *cc, struct page *page, - unsigned long pfn) -{ - return false; -} #endif /* CONFIG_COMPACTION */ /* @@ -895,7 +866,6 @@ static bool too_many_isolated(pg_data_t *pgdat) if (!valid_page && IS_ALIGNED(low_pfn, pageblock_nr_pages)) { if (!cc->ignore_skip_hint && get_pageblock_skip(page)) { low_pfn = end_pfn; - page = NULL; goto isolate_abort; } valid_page = page; @@ -1021,11 +991,20 @@ static bool too_many_isolated(pg_data_t *pgdat) lruvec_memcg_debug(lruvec, page); - /* Try get exclusive access under lock */ - if (!skip_updated) { + /* + * Indicate that we want exclusive access to the + * rest of the pageblock. + * + * The LRU flag prevents simultaneous access to the + * first PFN, and the LRU lock helps to prevent + * simultaneous update of multiple pageblocks shared + * in the same bitmap. + */ + if (page == valid_page) { + if (!cc->ignore_skip_hint && + !cc->no_set_skip_hint) + set_pageblock_skip(page); skip_updated = true; - if (test_and_set_skip(cc, page, low_pfn)) - goto isolate_abort; } } @@ -1098,15 +1077,9 @@ static bool too_many_isolated(pg_data_t *pgdat) if (unlikely(low_pfn > end_pfn)) low_pfn = end_pfn; - page = NULL; - isolate_abort: if (lruvec) unlock_page_lruvec_irqrestore(lruvec, flags); - if (page) { - SetPageLRU(page); - put_page(page); - } /* * Updated the cached scanner pfn once the pageblock has been scanned