Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2853582rwd; Mon, 22 May 2023 05:27:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4NawWqPkw+Zj/XXAESGvGxZeIzxKXbt7q/Gzjy7/RjTXyigzNJZY3Kfuz62CVAzIRKMyyv X-Received: by 2002:a05:6a00:804:b0:64d:30d2:f5c6 with SMTP id m4-20020a056a00080400b0064d30d2f5c6mr14457351pfk.3.1684758462336; Mon, 22 May 2023 05:27:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684758462; cv=none; d=google.com; s=arc-20160816; b=xWOpFGMcxcwc+TPV4CHfwKJkin+MDCzjRTNo/Ej8R/WW2IWznfx+LopEStXxQdA6uL ngNv34wTn5hUF/GW28aRXbCiM/RgLO6g2daQ/JV5lFjEaVlH3MYJK7Q+5kzfM+4gujtq iLyvfh48A/6V3Z9a0rv1oNDRe9FcTN/QC1VZxVMQyFJ2IjabpAY+7bjbFy5VHQIfSVJx 26KpRH9nQfyTuU2kKX604aAkiJ/eGpQdjol1ib7BBJ5evXsJu/06RTRhH9lbDe5kmRY1 239vkRsnD+lpVfWwV5EMS9F+BH0h7XB6sPtEnA3KV5N/UpEe9pIF0PwJbwDr/ZCYeaEm 4tJA== 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=Imitl3XmvIuYq6/BvAGSFjVEXqrydT3kZuIQR9ROytI=; b=1FDhm2vO0FdJDa/k1YX3hYi1z+UspMtZgeMfExudeEJaJjpZwh1Boep/K19m4xS2S3 76Tp+FqUH8u2X2wL/B0MzV3akVxIgM49MHGNjpO5nJO2fYkK0lMnOGCQ3/Qh/WEgsVFS 4MQXevm4KT0JFd4L3roG/v1hayt9T3Xx9/ptJ2WC28kOfl6+AuVDZ8DvpYqzyDp5v+fM aJTChbtAe7GFcDK/JeXCSJ9qpQ+u3PwQ9H8xQgL6wqka6+WyFtNpxYfAOIrnxB2qBCEN ZaGlI7CYz4fTYFpf4QRGrbirMPxtmikBaCKJL6qooOm+8Y2jFVxTplb0F1MY1PthEclo TAJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=JIyvdenJ; 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 185-20020a6301c2000000b005004b2acf6dsi1391512pgb.810.2023.05.22.05.27.28; Mon, 22 May 2023 05:27:42 -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=JIyvdenJ; 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 S233592AbjEVMMf (ORCPT + 99 others); Mon, 22 May 2023 08:12:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233267AbjEVMM1 (ORCPT ); Mon, 22 May 2023 08:12:27 -0400 Received: from out-54.mta1.migadu.com (out-54.mta1.migadu.com [IPv6:2001:41d0:203:375::36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAECFC2 for ; Mon, 22 May 2023 05:11:50 -0700 (PDT) Message-ID: <0e3c5937-2f04-25d9-98eb-01e4c2b04150@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1684757508; 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=Imitl3XmvIuYq6/BvAGSFjVEXqrydT3kZuIQR9ROytI=; b=JIyvdenJTXf8pd0kQ2NvebD93jjazdpK4xa6MgMCaYY2TlYn6la3ZbG7++GB6AIJ2BQUku finxRbja+B1dKyFuDllep0M1mDiaM9YKiIRgutHjRQUQnoW3ZTHbiRXiIPZLPC1Mn1PMBn r1yglYHh+y6svR/SIRs355RT0dUwsPc= Date: Mon, 22 May 2023 20:11:36 +0800 MIME-Version: 1.0 Subject: Re: [PATCH 13/31] mm/hmm: retry if pte_offset_map() 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> <2edc4657-b6ff-3d6e-2342-6b60bfccc5b@google.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Qi Zheng In-Reply-To: <2edc4657-b6ff-3d6e-2342-6b60bfccc5b@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 13:05, Hugh Dickins wrote: > hmm_vma_walk_pmd() is called through mm_walk, but already has a goto > again loop of its own, so take part in that if pte_offset_map() fails. > > Signed-off-by: Hugh Dickins > --- > mm/hmm.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/mm/hmm.c b/mm/hmm.c > index e23043345615..b1a9159d7c92 100644 > --- a/mm/hmm.c > +++ b/mm/hmm.c > @@ -381,6 +381,8 @@ static int hmm_vma_walk_pmd(pmd_t *pmdp, > } > > ptep = pte_offset_map(pmdp, addr); > + if (!ptep) > + goto again; > for (; addr < end; addr += PAGE_SIZE, ptep++, hmm_pfns++) { > int r; > I haven't read the entire patch set yet, but taking a note here. The hmm_vma_handle_pte() will unmap pte and then call migration_entry_wait() to remap pte, so this may fail, we need to handle this case like below: diff --git a/mm/hmm.c b/mm/hmm.c index 6a151c09de5e..eb726ff0981c 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -276,7 +276,8 @@ static int hmm_vma_handle_pte(struct mm_walk *walk, unsigned long addr, if (is_migration_entry(entry)) { pte_unmap(ptep); hmm_vma_walk->last = addr; - migration_entry_wait(walk->mm, pmdp, addr); + if (!migration_entry_wait(walk->mm, pmdp, addr)) + return -EAGAIN; return -EBUSY; } @@ -386,6 +387,8 @@ static int hmm_vma_walk_pmd(pmd_t *pmdp, r = hmm_vma_handle_pte(walk, addr, end, pmdp, ptep, hmm_pfns); if (r) { + if (r == -EAGAIN) + goto again; /* hmm_vma_handle_pte() did pte_unmap() */ return r; } Of course, the migration_entry_wait() also needs to be modified. -- Thanks, Qi