From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-182.mta0.migadu.com (out-182.mta0.migadu.com [91.218.175.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 52DA32EA75E for ; Wed, 22 Jul 2026 06:23:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784701411; cv=none; b=UtKcc5A69Kue8JjxFYghPVAvOzqqCZHvhNLM9fYZRh3NpVFlCN/SX/XXkTpaZ5cT75pFPX+qd9cZzGve0a8OL2wzlrbZpxiUcqxDM3jp9iHUee7/tBBXHefpxvHtlnOw+SCTaC07OlDBIlb++tOjCBYTqAWQUUeVeHLQq/xBmm8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784701411; c=relaxed/simple; bh=KRW2REjNKBN+qHOMAK4/eHa6Ktf5fAawbWDvXzUyHpE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fKcoJIsynLckGypakkW56oCimNpkrV8XQOsa8arh0zjUSiJbFQq1zwxmglrAwBAMgObn0FoxgcGNnyvwBp5bV3ggg3OHjxhUN1H1bnWnB32pZVjqVrHM4CDS7UumDtt5wKQchcSzZZUnPhoFQGfhCHJP0gEkrcVqEfADnbVv9VU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=tzNq2ujD; arc=none smtp.client-ip=91.218.175.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="tzNq2ujD" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1784701407; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y+uZjLLQiIyJL0MNzejDqd3cWL8cnK0hiaCvU3lz9wA=; b=tzNq2ujDDloIPimF2kNcLfziGZkN9+cx5QiImual87rKZ1RhOi2sXu7LV06DGOMeuxcaqk Aw5LgO6eTu/mVxB5SJufTWiCxsFIWSkuIdi8mdNdz5nhodQuGRZEoh4TNDb0uGPX9/idfl 2VzKxLsyLeOoNvDCeSQebtG+22IcZTU= From: Hongfu Li To: akpm@linux-foundation.org Cc: david@kernel.org, hongfu.li@linux.dev, liam@infradead.org, lihongfu@kylinos.cn, linux-kernel@vger.kernel.org, linux-mm@kvack.org, ljs@kernel.org, mhocko@suse.com, rppt@kernel.org, surenb@google.com, vbabka@kernel.org Subject: Re: [PATCH] mm/memory: use folio lock/ref helpers in do_swap_page Date: Wed, 22 Jul 2026 14:23:15 +0800 Message-ID: <20260722062315.43584-1-hongfu.li@linux.dev> In-Reply-To: <20260721180232.0984ad6fd55ad43053b3a079@linux-foundation.org> References: <20260721180232.0984ad6fd55ad43053b3a079@linux-foundation.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT > > --- a/mm/memory.c > > +++ b/mm/memory.c > > @@ -4852,6 +4852,8 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) > > vmf->page = softleaf_to_page(entry); > > ret = remove_device_exclusive_entry(vmf); > > } else if (softleaf_is_device_private(entry)) { > > + struct folio *fault_folio; > > + > > if (vmf->flags & FAULT_FLAG_VMA_LOCK) { > > /* > > * migrate_to_ram is not yet ready to operate > > @@ -4863,6 +4865,7 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) > > } > > > > vmf->page = softleaf_to_page(entry); > > + fault_folio = page_folio(vmf->page); > > vmf->pte = pte_offset_map_lock(vma->vm_mm, vmf->pmd, > > vmf->address, &vmf->ptl); > > AI review thinks we shouldn't be reading vmf->page until after taking > the page table lock: > > https://sashiko.dev/#/patchset/20260721013347.65698-1-hongfu.li@linux.dev Thanks for the review. The AI review makes a valid observation: `vmf->page` should not be accessed before holding the page table lock. I've moved `fault_folio = page_folio(vmf->page)` after `pte_offset_map_lock()` and the PTE validation check, so `vmf->page` is now read under the page table lock. This fix will be included in v2. Best regards, Hongfu