From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C93EC7EE2F for ; Mon, 22 May 2023 12:27:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233635AbjEVM1r (ORCPT ); Mon, 22 May 2023 08:27:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233106AbjEVM0w (ORCPT ); Mon, 22 May 2023 08:26:52 -0400 Received: from out-19.mta1.migadu.com (out-19.mta1.migadu.com [IPv6:2001:41d0:203:375::13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46E17E0 for ; Mon, 22 May 2023 05:25:03 -0700 (PDT) Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1684758301; h=from:from: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=r1IveFjFr/0G5nfPmQ1aYDtWSC7eo753hQs8Co832NI=; b=jE9wkVE1qhHuRF/ah9JoCOIcSKA1B5FaHdoFa8smx3qZO2ktUEzWV+AR/VczQifC9+sOee TiXSanP8l15OrBvvOE0EBtkNnPiIQtpkyn/FTyvbZf9T+d9sb+mV5vS1dEQ4wTiFdAyfoU ejXCpsZ0kjD0eVff0b56qxa/xQAqsJg= Date: Mon, 22 May 2023 20:24:45 +0800 MIME-Version: 1.0 Subject: Re: [PATCH 17/31] mm/various: give up if pte_offset_map[_lock]() fails Content-Language: en-US To: Hugh Dickins , Andrew Morton Cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Yang Shi , Mel Gorman , Peter Xu , Peter Zijlstra , Will Deacon , Yu Zhao , Alistair Popple , Ralph Campbell , Ira Weiny , Steven Price , SeongJae Park , Naoya Horiguchi , Christophe Leroy , Zack Rusin , Jason Gunthorpe , Axel Rasmussen , Anshuman Khandual , Pasha Tatashin , Miaohe Lin , Minchan Kim , Christoph Hellwig , Song Liu , Thomas Hellstrom , linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <68a97fbe-5c1e-7ac6-72c-7b9c6290b370@google.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Qi Zheng In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/5/22 13:10, Hugh Dickins wrote: > Following the examples of nearby code, various functions can just give > up if pte_offset_map() or pte_offset_map_lock() fails. And there's no > need for a preliminary pmd_trans_unstable() or other such check, since > such cases are now safely handled inside. > > Signed-off-by: Hugh Dickins > --- > mm/gup.c | 9 ++++++--- > mm/ksm.c | 7 ++++--- > mm/memcontrol.c | 8 ++++---- > mm/memory-failure.c | 8 +++++--- > mm/migrate.c | 3 +++ > mm/swap_state.c | 3 +++ > 6 files changed, 25 insertions(+), 13 deletions(-) > [...] > diff --git a/mm/migrate.c b/mm/migrate.c > index 3ecb7a40075f..308a56f0b156 100644 > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -305,6 +305,9 @@ void migration_entry_wait(struct mm_struct *mm, pmd_t *pmd, > swp_entry_t entry; > > ptep = pte_offset_map_lock(mm, pmd, address, &ptl); > + if (!ptep) > + return; Maybe we should return false and let the caller handle the failure. > + > pte = *ptep; > pte_unmap(ptep); > > diff --git a/mm/swap_state.c b/mm/swap_state.c > index b76a65ac28b3..db2ec85ef332 100644 > --- a/mm/swap_state.c > +++ b/mm/swap_state.c > @@ -734,6 +734,9 @@ static void swap_ra_info(struct vm_fault *vmf, > > /* Copy the PTEs because the page table may be unmapped */ > orig_pte = pte = pte_offset_map(vmf->pmd, faddr); > + if (!pte) > + return; Ditto? > + > if (fpfn == pfn + 1) { > lpfn = fpfn; > rpfn = fpfn + win; -- Thanks, Qi