From patchwork Sun Apr 4 15:33:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xu, Yanfei" X-Patchwork-Id: 12182313 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,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, 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 5EB01C433B4 for ; Sun, 4 Apr 2021 15:33:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 06DAE611C0 for ; Sun, 4 Apr 2021 15:33:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 06DAE611C0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=windriver.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 507636B0075; Sun, 4 Apr 2021 11:33:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 49B056B0078; Sun, 4 Apr 2021 11:33:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1FBF76B007B; Sun, 4 Apr 2021 11:33:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0200.hostedemail.com [216.40.44.200]) by kanga.kvack.org (Postfix) with ESMTP id D84C26B0075 for ; Sun, 4 Apr 2021 11:33:29 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 9F1A9180137B8 for ; Sun, 4 Apr 2021 15:33:29 +0000 (UTC) X-FDA: 77995078938.18.FF5DBA9 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2043.outbound.protection.outlook.com [40.107.93.43]) by imf06.hostedemail.com (Postfix) with ESMTP id C0EFEC0001EA for ; Sun, 4 Apr 2021 15:33:29 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iyKLML+beuTlEPu7EBWQsfEfbGwHAPIqnmEoRLIgjshc5GMpQ/0nqr9/2HxKnDV9ggw7zz6mCBQrJ8+a0PxQsjboO23Q4sfLRJRUdUMoMuqLrEhVhi1S7bXNyKNFw4vSFUR3Zpa9N1mFJh7jTS4hvKaBn6R9ohMajRCkdFAHD0lkN8/1znxOjlinl/sJq5n2y73pp+E83SbAfOrTSpFg0mIW7IvhLWJfN6YRMI0Gk2TiNkD+IFcPGEWdxC40mzn/dFB12Q4PnviIVz8dWUmzsunXYg1WbKk0SR6iZFVm2MWjhjoW8xhpwQ8FX05157NYLzr+P11Q+mqggCEG7JrkIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cBkUAvrWoH0M9to+Si6RvJubAPrImmTr3ieGP5fHuCs=; b=bpp0n9jvRcnFHhcmYBVwHbPwmYQLVocYtPszOvHQK8nyrIMuRNV+nIaKg3Qe+hZXv9S4JbigbnRKyoy4+rZgi+dmQJm8maYD08XU/i0pO+anAG7H66I9MGmxS84FI2Asfu/XiZ2lBSE3NBhjnoRTtKLUh0ewzT/TRxqnEytYMTX7sk3e8q5WlOtr5VoA2MHALcWjIBQ85J4UbYEuMXHCHDkpL83YBwWT466omChmarGhbTBRdvh93nqGb1b6zvudS8nQDQ6e5ecFMipa8lrwOdoTDPwezfZZ/IaRBa9F2XxSEAl5buDgF3Ku1+Ooa597MbGj5RZB1wNpBc0a5uVzrw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriversystems.onmicrosoft.com; s=selector2-windriversystems-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cBkUAvrWoH0M9to+Si6RvJubAPrImmTr3ieGP5fHuCs=; b=G5bnXblui2fxbFnHeMPf5Obrxtal+54xz2YZXvL5SUTlkh7UqXvYRlfzlW5IFt7EktRdukno+2C4iJwtc2M/U39TYGFure7pXydyrFKZBeLHcLZRuOuTOYTEnsvgIeMPxD0ai3kWV5GQF1CVmVkg6GsKpylunO2T28Svk8lQM6M= Authentication-Results: kvack.org; dkim=none (message not signed) header.d=none;kvack.org; dmarc=none action=none header.from=windriver.com; Received: from BY5PR11MB4241.namprd11.prod.outlook.com (2603:10b6:a03:1ca::13) by BY5PR11MB4181.namprd11.prod.outlook.com (2603:10b6:a03:18c::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26; Sun, 4 Apr 2021 15:33:26 +0000 Received: from BY5PR11MB4241.namprd11.prod.outlook.com ([fe80::551b:e310:2ae4:3011]) by BY5PR11MB4241.namprd11.prod.outlook.com ([fe80::551b:e310:2ae4:3011%6]) with mapi id 15.20.3999.032; Sun, 4 Apr 2021 15:33:25 +0000 From: yanfei.xu@windriver.com To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] mm: khugepaged: check MMF_DISABLE_THP ahead of iterating over vmas Date: Sun, 4 Apr 2021 23:33:11 +0800 Message-Id: <20210404153311.1460106-3-yanfei.xu@windriver.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210404153311.1460106-1-yanfei.xu@windriver.com> References: <20210404153311.1460106-1-yanfei.xu@windriver.com> X-Originating-IP: [60.247.85.82] X-ClientProxiedBy: HK2PR02CA0136.apcprd02.prod.outlook.com (2603:1096:202:16::20) To BY5PR11MB4241.namprd11.prod.outlook.com (2603:10b6:a03:1ca::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pek-lpggp1.wrs.com (60.247.85.82) by HK2PR02CA0136.apcprd02.prod.outlook.com (2603:1096:202:16::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.26 via Frontend Transport; Sun, 4 Apr 2021 15:33:24 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 62a77ed0-487b-42f5-9d3c-08d8f77efd01 X-MS-TrafficTypeDiagnostic: BY5PR11MB4181: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4502; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jZmkmNdDRQs41HFQtdQo1YO+oL2bT5cfpDK/BLvc9lzwn/MEnee2qWoIVku0bBvCahwmWnMuDOErY46w8KHA0CbPdtwDtwCZnYktPLkbjVYpDmBmnNSqXz74fKnBXhclouJHl7cgqU8f50L14wkOwlw/D9CqXhk8CC8p7kZeuNfwvg91lfcbVYWiuQ/EJekouyTo/4vok/xzRwGTugVVostcp5L8gosvaONf2l3b2ZeYLvf6MCJclCftCwlQnFYbskrlBsR7GaRNmCXeL9RXOCBOxhjJogO8VHqIuI9MInRwNFkx93+kO8K1+hJGAxsM56DevTkfWKdxSoO7hds7rh1bDmiiLTGqGoK8XmlaiALxc3kYxlCf9WK3EJLYVIKINxO0pBEreBrMwF96I+tYQNQmvkkRflq/JSySJvNnGSmbIgIHe+plYpGCelR4vOsCvaeBOqHcobj+QqnRSiuWj2JNUyLj3pGQIlP55GjvHJ52/NVxYZCvvsAzfJkp2UWXP3VAZmdcR5czU032aTul8OBbR2I/c1HY5KsAJa0uz4bh/Yz91jknMbyKP3tuxhNLJgWcCvmUn2j94sqPmgcq5RmBkeAydnklSqk+q1wMWTr+ZfJqtjXf7P75k/hvsFOt5H8oCNDcoHUTWbFuffhk5g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR11MB4241.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(136003)(376002)(396003)(39830400003)(346002)(186003)(16526019)(6486002)(8936002)(1076003)(36756003)(6506007)(86362001)(83380400001)(8676002)(956004)(6666004)(5660300002)(52116002)(38100700001)(9686003)(6512007)(2616005)(66556008)(66476007)(66946007)(2906002)(478600001)(316002)(26005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: bMnGw+XPSNQ4DA++aDeshtyaLZQFBVGWbeUdc1nQpoCAcdUcafNAci/Be4IC7HzP8jkWzK2/G/vHDMgl2RvvdiKeX2/t7wt4m87zF+4QqV/vvt0zVqq5Y9ndmOEWR+taVfY5dwB2/A8jsThLG9tPSblJxZCAG1q95t4+Hzj8n2rC6VZGVM4cumpQ5tO8qV5b5PE9UkTb6lfJYPobfHgtiOrthUgQ9AUrJewOBVqTZf6ktGCN3cJnqzPGKjJ67eh9qrlgnC9WNnI1qF6c5ndKl6W3K5NxcN7bhfPzPMBgLa7wpS/i5vnqnrbSPsGPfkpP7/hxvX4qFBtctb8JzfmD1gdq0CKPheb3EL1EXC055pNxHbNnk3Om2T6Xyx3zlHPeb6NaH4CNVw4jGK3BYmpnYKSVdhHQGfExFKQJ4ChpUpD94czom9Daa+Du9rEkRcZMbeYDzicl1LOElBuUWgbEX+ZSip846IuDtJ2KUdaF749woGCUYe0DrBVehWJPFr5LrK376uk4bx/MnsEd/Gl6z8GCJYW6PqZXK8BPG74YVXo4gzBFC3oxnyyCzS8AaJxTf4sDj+/td1DDobXy3MFesnV0GtyK0jGGYpzUlE7650ceDDXoePNvNgH19XbDlbYQWmjZRMh+QHmno8vpt02YZT3zowEqoPMN+mnrHL6S9PDXPOmh2aa74/qOeN35sHEAjQ37y5Uxib2qw1vRd5W/t5R/zUzS7PIPGWy8kiVZArCBopPNuXRfXrvXPCOqM28xj5lCZvWngBJixdMQ74gHXmG2eubhK8B/3x8xaPP6Fh7O3v/2fMzggSoo7X+3PvoAgL1QyEIptmsxXsXy3v/xUw+19xuliAfn4n4btU0cO6KRUdQ7yn47Gnxfq1CpiaKuHEzypYUo540Cxok5MMsG5AMKS5I9H4KGtxgoTAEPZ3mHpY7bMh2gU0zPWrwx1tfabwwRr9y676quKnU91VS7BpZB2CzIfjZ57L6/PjmCJlXa/gVTs38JwBKI/xS2jVjdLD6LpQuKVwjvOTzfuxADuGGfMsMKqGUqAw9QyNxssh1xxJWk3NY1clpvCn1XKbWm43QMM4UinEQ5D5g1AfydOaTb94vO+iOvKzCcW0JLlR6O9yccqsr+LtBMZr1aKjEbB4rz6l944ktFRkHGarSjC4ZFCciJTPqydinzo3mpNcGvdVtnjeTWurqAcONpdPmdQZob+dgIkYxX4WHTlb7oBsuQdVUQktiUErMBF1GROJyWT0EHapr4VA1jjmFUMT1TJsIjvttujEmEWbdCYLuVIb1f2800LGDZd/dfHMcVkq4aAN0pGLvfosbFujJhhJXc X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 62a77ed0-487b-42f5-9d3c-08d8f77efd01 X-MS-Exchange-CrossTenant-AuthSource: BY5PR11MB4241.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Apr 2021 15:33:25.8924 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8ZJHoXGEGZ/om2O9g5HAaZQnfTfEwSTqqFvDnZo5BcwK2urRlPvf1BU4P0Lj+e4ONRT/ODMhexyHPar/wYRYPw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR11MB4181 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: C0EFEC0001EA X-Stat-Signature: imebsftfud57o4wnzbptzx41njxk7411 Received-SPF: none (windriver.com>: No applicable sender policy available) receiver=imf06; identity=mailfrom; envelope-from=""; helo=NAM10-DM6-obe.outbound.protection.outlook.com; client-ip=40.107.93.43 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1617550409-122542 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: Yanfei Xu We could check MMF_DISABLE_THP ahead of iterating over all of vma. Otherwise if some mm_struct contain a large number of vma, there will be amounts meaningless cpu cycles cost. BTW, drop an unnecessary cond_resched(), because there is a another cond_resched() followed it and no consumed invocation between them. Signed-off-by: Yanfei Xu --- mm/khugepaged.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 2efe1d0c92ed..c293ec4a94ea 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -2094,6 +2094,8 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages, */ if (unlikely(!mmap_read_trylock(mm))) goto breakouterloop_mmap_lock; + if (test_bit(MMF_DISABLE_THP, &mm->flags)) + goto breakouterloop_mmap_lock; if (likely(!khugepaged_test_exit(mm))) vma = find_vma(mm, khugepaged_scan.address); @@ -2101,7 +2103,6 @@ static unsigned int khugepaged_scan_mm_slot(unsigned int pages, for (; vma; vma = vma->vm_next) { unsigned long hstart, hend; - cond_resched(); if (unlikely(khugepaged_test_exit(mm))) { progress++; break;