Message ID | 20231119194740.94101-18-ryncsn@gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 8791AC072A2 for <linux-mm@archiver.kernel.org>; Sun, 19 Nov 2023 19:49:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 15FFB6B03B9; Sun, 19 Nov 2023 14:49:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 10E446B03BB; Sun, 19 Nov 2023 14:49:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EF2406B03BE; Sun, 19 Nov 2023 14:49:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id DB8516B03B9 for <linux-mm@kvack.org>; Sun, 19 Nov 2023 14:49:00 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id BAF091604AB for <linux-mm@kvack.org>; Sun, 19 Nov 2023 19:49:00 +0000 (UTC) X-FDA: 81475742040.04.229F568 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by imf02.hostedemail.com (Postfix) with ESMTP id DB25780017 for <linux-mm@kvack.org>; Sun, 19 Nov 2023 19:48:58 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="gi+U4qw/"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.210.175 as permitted sender) smtp.mailfrom=ryncsn@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700423338; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=FCPW0dI33gWre1bmPp4wG3A/kpp2Dtpn+fZQd/yP8/o=; b=YSN+97syxJcbrK+Azl06Ai36LHwPDaj+lcIHBojYDVSDSt8zH/FUnKIoMvQYlECAeIToTf ZDQHuLjZYqrSayBGUN98qYD2BTkMqupltoc+ZLWZLh6AK0v624Xzbef2yTzQjwbe2OsdzI 9XXjntFjMSdzG9+hrrnw02ONZd9XPJ4= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b="gi+U4qw/"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.210.175 as permitted sender) smtp.mailfrom=ryncsn@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700423338; a=rsa-sha256; cv=none; b=CDQ1I8S3BCI+4TRZXnjQWtzGt5bqv8wiaRFcl6gdOFslBTLoFUrld0U8ijUOfKvJoAcZof 7F51oZ3q25O3tUkcVa+UWBQm4aYOnXnYZKZSPd1YiTVQmo0y2wdvQH4PMgN54hItpzpssO 1ElLIv7L8ia9QCq+VrrJlr7L10jZQEY= Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-6b2018a11efso3881502b3a.0 for <linux-mm@kvack.org>; Sun, 19 Nov 2023 11:48:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700423337; x=1701028137; darn=kvack.org; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=FCPW0dI33gWre1bmPp4wG3A/kpp2Dtpn+fZQd/yP8/o=; b=gi+U4qw/5tZAF53CaXVqhJ2hOviCi6bU7ZwkcSeE12bw1MsntwCxdS7VbEJBFnw6EZ xBSoB7OwjhQcg5muYNV/6RNszjU/V71cSmar6owKOaCvzcpu16HgHuxc7YLryas3/jww WOAw8Yx+H1vOMjVhqnhcl3ccCGuf66WgaZG4w7pqEnkM45q7irDiXgvv94vuPB2P6JTT ZHSvGY+qdQUmqMj4buGyrNYeG8vc6JTCZz44UQsTMDfzKOxFJHtiMHcMRVF19mYmTulH +K12sRlobTkWqeBR2qsEFnUVoBPpEJLlCCfkb+0qPv/DzdOX/mCR7a6nNHJOFBrUi1UL +hkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700423337; x=1701028137; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=FCPW0dI33gWre1bmPp4wG3A/kpp2Dtpn+fZQd/yP8/o=; b=gkTRjWaHCHF+1w65i8vHtSnQx5rnWqpa3PHBZIEf+/Xv+txfTq7RC0wJRM6WeaCyWj fCtk5rAkX5fdaihqBK98mg9DDo33zEgSbKOwxOqJyK0Dy1DT5mLC9YPKIZ2ePeDFjIsE gBjb6BudNx7ru0COR7TkYPTn5+j2rjZNih7kA/BGmrSGLyfk0WCHRZwKQO/18oZMpWu2 HBr+l207fy+onc0xB1WbKceNPHRvhlZdNi32NPcICtfm886xjoXA19pQVDY4dyKJiVji t4ZhHPNJVP9jffSGeB7Kv5s5Lx8ysKJ2hp/s7rzzC9VKK6kq0HprcXJXlXfwkKPPA3Ex 9JeA== X-Gm-Message-State: AOJu0YzNiOa6vJyknpexaZhSdo54EVaOb8FTQo7fCnKYekhFCN/BCOLa 50zPck9iAAHEncI29tj33wwcZKcNDGzoZhKB X-Google-Smtp-Source: AGHT+IF9QoAWouGwWEXuyCQ9NU0AgZDxQWALIyGpxr9BM9RgNBGPUMqyqjGgp7YBTc1CUFiZCcylkA== X-Received: by 2002:a05:6a20:244e:b0:187:f23d:f9f2 with SMTP id t14-20020a056a20244e00b00187f23df9f2mr6715469pzc.58.1700423336700; Sun, 19 Nov 2023 11:48:56 -0800 (PST) Received: from KASONG-MB2.tencent.com ([115.171.40.79]) by smtp.gmail.com with ESMTPSA id a6-20020aa78646000000b006cb7feae74fsm1237140pfo.164.2023.11.19.11.48.53 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 19 Nov 2023 11:48:56 -0800 (PST) From: Kairui Song <ryncsn@gmail.com> To: linux-mm@kvack.org Cc: Andrew Morton <akpm@linux-foundation.org>, "Huang, Ying" <ying.huang@intel.com>, David Hildenbrand <david@redhat.com>, Hugh Dickins <hughd@google.com>, Johannes Weiner <hannes@cmpxchg.org>, Matthew Wilcox <willy@infradead.org>, Michal Hocko <mhocko@suse.com>, linux-kernel@vger.kernel.org, Kairui Song <kasong@tencent.com> Subject: [PATCH 17/24] mm/swap: fix false error when swapoff race with swapin Date: Mon, 20 Nov 2023 03:47:33 +0800 Message-ID: <20231119194740.94101-18-ryncsn@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231119194740.94101-1-ryncsn@gmail.com> References: <20231119194740.94101-1-ryncsn@gmail.com> Reply-To: Kairui Song <kasong@tencent.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: DB25780017 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 377xcpi63umsiwngymsd5dyuo9x4phsk X-HE-Tag: 1700423338-955692 X-HE-Meta: U2FsdGVkX18yKcwAqGkRpj+4+YcOrmam+SGDKUN4CT8OqMmZuhAjAeO3wLR1qNLpMfYNRy0sHriQNweeNS9tsMXdoJzVSFasvWFFnn7vRuCX3KNDKPDCnjjGE+HtMfydvD2PuVFIbJpMEgoVr/F6o7/KZblqRfTMJK3DNEUK7vi1o8IorTP2cyVgoKqYnaDNucgFfXBc+AaDAPE07+pLjr6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yo2DuJ0Dg8VkciLct2Vu1LOv+YLvgVvbgWFCq6x4Ql4om0MLKzIweAhyR6gvkaTnRppmGNtTwIEJkfuO4r/KZ3qdnuEmqCyPolEDwAh5cxwKN1kcLNUWYEoegZT/a71YWwkVFgnIWgI3gSNA0w8OCqH0kOK3Y7Gi9/KZ+aIJIJhvbykgYMwVe2ifHrnLC7rXg6l0ZeZUzS9nJ13YAjY1dfKhci2NeunUiSveowMyPLcO+UCus4njY5F03ik+sKeNHaw6XM0IVFdjCqK2IwAx9HCgU+M5kf6RrC+nIHzAykcoeXEVilOU/o3l4i86yRZYZc0OcOiiEuwI3sozLMRF 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: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
Swapin path refactor for optimization and bugfix
|
expand
|
diff --git a/mm/memory.c b/mm/memory.c index e399b37ef395..620fa87557fd 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3846,9 +3846,21 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) page = swapin_readahead(entry, GFP_HIGHUSER_MOVABLE, vmf, &cache_result); - if (PTR_ERR(page) == -EBUSY) { - goto out; - } else if (page) { + if (IS_ERR_OR_NULL(page)) { + /* + * Back out if somebody else faulted in this pte + * while we released the pte lock. + */ + vmf->pte = pte_offset_map_lock(vma->vm_mm, vmf->pmd, + vmf->address, &vmf->ptl); + if (likely(vmf->pte && pte_same(ptep_get(vmf->pte), vmf->orig_pte))) { + if (!page) + ret = VM_FAULT_OOM; + else + ret = VM_FAULT_RETRY; + } + goto unlock; + } else { folio = page_folio(page); if (cache_result != SWAP_CACHE_HIT) { /* Had to read the page from swap area: Major fault */ @@ -3866,17 +3878,6 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) ret = VM_FAULT_HWPOISON; goto out_release; } - } else { - /* - * Back out if somebody else faulted in this pte - * while we released the pte lock. - */ - vmf->pte = pte_offset_map_lock(vma->vm_mm, vmf->pmd, - vmf->address, &vmf->ptl); - if (likely(vmf->pte && - pte_same(ptep_get(vmf->pte), vmf->orig_pte))) - ret = VM_FAULT_OOM; - goto unlock; } ret |= folio_lock_or_retry(folio, vmf);