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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67B2BC433FE for ; Wed, 2 Nov 2022 20:47:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E85188E0002; Wed, 2 Nov 2022 16:47:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E0E3D8E0001; Wed, 2 Nov 2022 16:47:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CAF948E0002; Wed, 2 Nov 2022 16:47:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id B76568E0001 for ; Wed, 2 Nov 2022 16:47:18 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 9450AA1220 for ; Wed, 2 Nov 2022 20:47:18 +0000 (UTC) X-FDA: 80089687356.13.47B7753 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf16.hostedemail.com (Postfix) with ESMTP id 2BC58180002 for ; Wed, 2 Nov 2022 20:47:16 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 106EE61C11; Wed, 2 Nov 2022 20:47:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 313B6C433C1; Wed, 2 Nov 2022 20:47:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1667422035; bh=d734KrkzRNIacBzb1OxFoYKzAgC7fEMj8hqfCbnvm9I=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=a0q4o12/JDOBGm2H3Mr5hdID6PSu7nJbDbyNqRR3UC6NdO0H0C77bKf9PirJUZmE8 NDv9gR7zrJmOS6xFY5g6WrKhND3T3wKJu9rfgU9FfvFCPYyNPavKz9xmx+ZctKsNV8 hOvf0mQX01v5paVELSSwg3HLEhsq3Fgg9W/cPjsQ= Date: Wed, 2 Nov 2022 13:47:14 -0700 From: Andrew Morton To: Peter Xu Cc: Matthew Wilcox , "Vishal Moola (Oracle)" , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Hugh Dickins , Axel Rasmussen Subject: Re: [PATCH 3/5] userfualtfd: Replace lru_cache functions with folio_add functions Message-Id: <20221102134714.c72bea3c997ba3ef90d72c53@linux-foundation.org> In-Reply-To: References: <20221101175326.13265-1-vishal.moola@gmail.com> <20221101175326.13265-4-vishal.moola@gmail.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b="a0q4o12/"; spf=pass (imf16.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667422037; a=rsa-sha256; cv=none; b=k99dPnM5ca7iuMFREqXoRNoFLAkqFwaAbF1KhC2bmCt3waJOyIiMV5pTILP2xnmcPurtkl IB2ShOLQr2IxRC3haaEQrZADr7Dd3SSncv4m/S7scIr8KddEH8NlgTStsPJbNEHC1h7HKI xEeXrECqcBJnyf1gweCdajJ/icuAXQc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667422037; h=from:from:sender: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:dkim-signature; bh=uaCF0A4HmAUMYPMgjq27yJpUza9hZUGR+ug8Y02iFio=; b=Je7NbsrTrY/XRxorVY7L2KKumXOepDCN3csZ5NEm+4qL0+RxD+hHpLksQkYkEYxbkP6Gw3 pYpz7z9jsZts/Nm9N3iO8FfV1ADioJIobPlzb2jH9lFLwBw8YL2yIXN9q+baxNBD0Q5brN dmh68gcOK0UisLu2bYmz0NidFNT4rw8= X-Stat-Signature: frdjtpuy593yo9zr6a1txfgg7suksumi X-Rspamd-Queue-Id: 2BC58180002 X-Rspam-User: Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b="a0q4o12/"; spf=pass (imf16.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Rspamd-Server: rspam01 X-HE-Tag: 1667422036-101262 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: On Wed, 2 Nov 2022 15:02:35 -0400 Peter Xu wrote: > mfill_atomic_install_pte() checks page->mapping to detect whether one page > is used in the page cache. However as pointed out by Matthew, the page can > logically be a tail page rather than always the head in the case of uffd > minor mode with UFFDIO_CONTINUE. It means we could wrongly install one pte > with shmem thp tail page assuming it's an anonymous page. > > It's not that clear even for anonymous page, since normally anonymous pages > also have page->mapping being setup with the anon vma. It's safe here only > because the only such caller to mfill_atomic_install_pte() is always > passing in a newly allocated page (mcopy_atomic_pte()), whose page->mapping > is not yet setup. However that's not extremely obvious either. > > For either of above, use page_mapping() instead. > > And this should be stable material. I added Fixes: 153132571f02 ("userfaultfd/shmem: support UFFDIO_CONTINUE for shmem")