Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp203498iol; Sat, 11 Jun 2022 02:06:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnx1ouPrtMque/mMB09TpYaTnuGuS3E6z2KbBr38dhoQgV3yPAE1q3bfPtBKyYuZLiQDlv X-Received: by 2002:a05:6402:17d0:b0:42d:ccc1:f4e4 with SMTP id s16-20020a05640217d000b0042dccc1f4e4mr55500292edy.150.1654938415257; Sat, 11 Jun 2022 02:06:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654938415; cv=none; d=google.com; s=arc-20160816; b=SbZMsSPJWizMNMl+tld7g91SDdUDjIn+EcnORDYnX0ROFusS3A+slhFMr38PSdG/rz 3JOc+LTkaqdmY9/3/i300Jw4hUhNldCFZE73r/h9PHDSNfIPUNiV3Gc4f+JscrjqnHAV B4Y+Im979azjr2h/ik+Zf/i2qqERuh4K6p80ffN4auEV3MWN3iQMohuUHw3LVgT8c2Fe gAjXT8fgavY9oGQm7crIgs5SNFT6MCMxqyRTp2kww7Er7oVX4dAUxwjD09fzaCJs5gu2 56Z38uWjrCWeEZax122o2r+2JZXzP9w+W2oyZ7INaRQMfombN5xCqIqNp+VaM73tMNS0 hwlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=wqeufgo2DY2NVbnoL1afXs+2qFAB6HL/hx+nzZLN+tk=; b=RpznR2RTF1mVSQCZuV5tlLxXdnmoL3ts2oan25Qap2zCFXLE7t1TutTZAzFzvKC8aK yZJfjtRtoqleplSR0zNjD6SQpi1KBVnPc47SRKrtcJcGyWury2pIWeMeBKQ5uWv0fL/U PBLi+HCBq5QAa2kURM3kId50TLJssA5rZf974X13KEXP/hyr0Bmqw45pAdJJAX3lhFyN Ga1ij5jLmNuljhuq3VEnEQ5wB58PlmESlXD0d+8pynyHNEMQJIy+GnZjDXvlZ/y68j+7 8ygPB3wXLQZk5QxDHElPiEjq25/IIr0yoogFLyy/4yGY+Gi8uoosgCMstwXz5/wXZu76 b9DQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 4-20020a170906024400b007157046560csi334453ejl.884.2022.06.11.02.06.29; Sat, 11 Jun 2022 02:06:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231700AbiFKIri (ORCPT + 99 others); Sat, 11 Jun 2022 04:47:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231479AbiFKIrc (ORCPT ); Sat, 11 Jun 2022 04:47:32 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 416861ADB1 for ; Sat, 11 Jun 2022 01:47:30 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LKrz7716NzjWw6; Sat, 11 Jun 2022 16:46:27 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Sat, 11 Jun 2022 16:47:28 +0800 From: Miaohe Lin To: CC: , , , , , , , , , , , Subject: [PATCH 2/7] mm/khugepaged: stop swapping in page when VM_FAULT_RETRY occurs Date: Sat, 11 Jun 2022 16:47:26 +0800 Message-ID: <20220611084731.55155-3-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20220611084731.55155-1-linmiaohe@huawei.com> References: <20220611084731.55155-1-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When do_swap_page returns VM_FAULT_RETRY, we do not retry here and thus swap entry will remain in pagetable. This will result in later failure. So stop swapping in pages in this case to save cpu cycles. Signed-off-by: Miaohe Lin --- mm/khugepaged.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 73570dfffcec..a8adb2d1e9c6 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1003,19 +1003,16 @@ static bool __collapse_huge_page_swapin(struct mm_struct *mm, swapped_in++; ret = do_swap_page(&vmf); - /* do_swap_page returns VM_FAULT_RETRY with released mmap_lock */ + /* + * do_swap_page returns VM_FAULT_RETRY with released mmap_lock. + * Note we treat VM_FAULT_RETRY as VM_FAULT_ERROR here because + * we do not retry here and swap entry will remain in pagetable + * resulting in later failure. + */ if (ret & VM_FAULT_RETRY) { mmap_read_lock(mm); - if (hugepage_vma_revalidate(mm, haddr, &vma)) { - /* vma is no longer available, don't continue to swapin */ - trace_mm_collapse_huge_page_swapin(mm, swapped_in, referenced, 0); - return false; - } - /* check if the pmd is still valid */ - if (mm_find_pmd(mm, haddr) != pmd) { - trace_mm_collapse_huge_page_swapin(mm, swapped_in, referenced, 0); - return false; - } + trace_mm_collapse_huge_page_swapin(mm, swapped_in, referenced, 0); + return false; } if (ret & VM_FAULT_ERROR) { trace_mm_collapse_huge_page_swapin(mm, swapped_in, referenced, 0); -- 2.23.0