Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2895296rwd; Mon, 22 May 2023 06:03:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6C4KKtrH5CWZKAAreqHPHFwBn487WdCOhwf7OoBTpNnP2nRaASSr0FVfIvrbkpAnTPtXwq X-Received: by 2002:a05:6a20:4320:b0:100:6a95:c289 with SMTP id h32-20020a056a20432000b001006a95c289mr12961102pzk.5.1684760635282; Mon, 22 May 2023 06:03:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684760635; cv=none; d=google.com; s=arc-20160816; b=qtQiXSNh0jOe+kG4kagZ/qyEXXxfIImloYCbJOIgOsT48J8mWSQdtc4a5oXdckN1oq Bt/6CYt1cpNmOZ5TtYm5+hm/6HWoJl8SiYEgLIfQSfpN2QOcj0PSDh5BEe1frRz95EXM 63BKtqdM5uUHyR+1drrHYrinNgQ7XqfYl/LKlRWFGAXAf1Js7L9gNbpGezIrjQzaCTAV 4KlDwDK2VXLtrCJlPnFRSf3HaEJOS9Ytfkf/2dU3ajwFoBjfa3TLEePdTMNZ43qpiY2t XA5wx017d0akJLRfiO8XVHxareXVaG9Pb12aFnOrgyXKWTAS6hQIrz4g0khQSCu+TeSn jUcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:mime-version:date :dkim-signature:message-id; bh=8Vf55yronjbw4sVFWMpRa3/wf12y9L5bS4sB8okVwQ4=; b=DPXVXIOVK3/2jJcoCnZe6A5MV8M3rmuLkqYbmCELYjcmVf6Wwc8U5Lzb4pZveNvBp/ 1eS6u2NV3wtdXML05EvzGeHhszAg7SIuZ7nIMh2CmG9mCzWCcYc3WL788FvrOKZT8XEZ CiFgiGUEbLYYLHqlS2AuE+RqQjNc04rz5POVdzhQ2SFjWhkf01cOXAAWFt5N3qPoceAp PVtNTE1CbRFfJaujiqa5bHXK3ei4p8OiTGgru8JSMb6Ti1j6CzKazCR84Dm/60Gpq1Gt Tf1ljtnBVIYxcRmzcywvl4fX4cGprwbmJ1krxA7tx5MYkRIcXN5PinB+BKmstm3lMjrX n7mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=jXaiovzB; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z22-20020a63b916000000b00524cf947601si46549pge.23.2023.05.22.06.03.38; Mon, 22 May 2023 06:03: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; dkim=pass header.i=@linux.dev header.s=key1 header.b=jXaiovzB; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233559AbjEVMiH (ORCPT + 99 others); Mon, 22 May 2023 08:38:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233182AbjEVMiD (ORCPT ); Mon, 22 May 2023 08:38:03 -0400 Received: from out-51.mta1.migadu.com (out-51.mta1.migadu.com [95.215.58.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3520F9 for ; Mon, 22 May 2023 05:37:44 -0700 (PDT) Message-ID: <07317766-c901-34a9-360a-e916db4b9045@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1684759063; 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=8Vf55yronjbw4sVFWMpRa3/wf12y9L5bS4sB8okVwQ4=; b=jXaiovzBiCse3JJSew7ABrQpqiKz5q/ZNG2KpsWelvRJoTKqKtEfMjviU4AIEkWIALNHIa kKysD7sKdNbc9KmProLOOQcLCexRdc8wGwbuYN5BCz6J4Jzg4/JZOqmE7pZ2Nv7Capzcto RSdtUQKNc2JoTgSP/J8hXW/Vtmv5SXs= Date: Mon, 22 May 2023 20:37:31 +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: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 On 2023/5/22 20:24, Qi Zheng wrote: > > > 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? Oh, I see that you handle it in the PATCH[22/31]. > >> + >>       if (fpfn == pfn + 1) { >>           lpfn = fpfn; >>           rpfn = fpfn + win; > -- Thanks, Qi