From patchwork Sat Jun 11 08:47:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12878375 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 D599EC43334 for ; Sat, 11 Jun 2022 08:47:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D0E938D0113; Sat, 11 Jun 2022 04:47:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CB80E8D010E; Sat, 11 Jun 2022 04:47:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B3B188D0114; Sat, 11 Jun 2022 04:47:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 9DFC68D0113 for ; Sat, 11 Jun 2022 04:47:35 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 7A5D6617F9 for ; Sat, 11 Jun 2022 08:47:35 +0000 (UTC) X-FDA: 79565326470.18.9951345 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf24.hostedemail.com (Postfix) with ESMTP id D7CD2180071 for ; Sat, 11 Jun 2022 08:47:34 +0000 (UTC) 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 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1654937255; a=rsa-sha256; cv=none; b=l+JDUV5bYlmt9kpwpdg52gz56EVmGOYL6qOYYiFFiPzE2WHY1eE8wch/0ChXhcb0dYbCfg +DezjWf+oP5SmRllVinhtoXYRPsOD8x0XFmyr3i/cVCDe8vRuX6OFO9ajdDnjoysDfk+fV S+8p/vnG+TWbMmhnj+wScWmfoYE4+RQ= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf24.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1654937255; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wqeufgo2DY2NVbnoL1afXs+2qFAB6HL/hx+nzZLN+tk=; b=xijOKN9UCTpSXLV/GKJZzwVwKPHpQtzMLIEpnKjGgmsJvT4B7DpN1s0TcnMXiV8HkhW+FT JhgVNG/IT36BOTGTApRFOp3CwZNQtkX1+h4e0P32DuHRv8LFsKhPLeNZGDmNnA8J7G6VQu glB5vL6CHbJHnQNesyKul5d1ERwOYDk= X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: D7CD2180071 Authentication-Results: imf24.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf24.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com X-Stat-Signature: 3k5gfajxdpr4bdh9xza93poiygbh3464 X-HE-Tag: 1654937254-329451 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: 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);