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 CBA42C433FE for ; Wed, 2 Nov 2022 19:21:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 43E258E0002; Wed, 2 Nov 2022 15:21:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3EEA48E0001; Wed, 2 Nov 2022 15:21:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2B7118E0002; Wed, 2 Nov 2022 15:21:21 -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 1C1FE8E0001 for ; Wed, 2 Nov 2022 15:21:21 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id CD64480207 for ; Wed, 2 Nov 2022 19:21:20 +0000 (UTC) X-FDA: 80089470720.18.CE79B63 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf02.hostedemail.com (Postfix) with ESMTP id C259780006 for ; Wed, 2 Nov 2022 19:21:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=utt30JAJTgovEUnU7oZUHBSJjF7rzQywZWScCNuHRzY=; b=WPA3CheUPO+l2TLbtJ8F4sMjDY wuzW0rXM8/YT9+GS5bvCyNPAOVDTCdMZDfDmnEQ43hM8popaQVmO8joNM3aFWyHduRQ4eui3OXRgq eSafeyeT0YVoCmB3xSkQ6blaJFiS/555XUSI8y8stBxOr6eRzE5h1Gs8G6a1fiQz7ew/m2QUbY+D5 mA6b3eEuM+tkoyEHlmtTZHUjmeqoL7Qfi9TYfB9VSYpeMkhLIREIFq0uDEVrRSvjSq/3ahoR9Qfor 7/2A4QwC7pJ/PLrhQx2mIAtD6jS/CMbSMq2cnEwkdIUybVR4+Zkpju3W6ThTOF1jzL6Ryq/ih3woJ cyc5vPEg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqJId-005mDl-8K; Wed, 02 Nov 2022 19:21:19 +0000 Date: Wed, 2 Nov 2022 19:21:19 +0000 From: Matthew Wilcox To: Peter Xu Cc: "Vishal Moola (Oracle)" , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, akpm@linux-foundation.org, Hugh Dickins , Axel Rasmussen Subject: Re: [PATCH 3/5] userfualtfd: Replace lru_cache functions with folio_add functions Message-ID: References: <20221101175326.13265-1-vishal.moola@gmail.com> <20221101175326.13265-4-vishal.moola@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=WPA3CheU; spf=none (imf02.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667416880; a=rsa-sha256; cv=none; b=Gmvmh7xSv/XI/WzjVcMIkRPQevDS7bc0eGZtG2/B4dgOuacZTi/+zd4wXUUPQWc0VKX/8h Apwbxm+gLSiqwVylGhP/QbzSa8EKrDeCj/R/fRFHHaEsIbIP6Aqlj7JKuY60cs6bkmDq+A QylCXTKMg4uwXtnTc6iWPY8QHMhNNd4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667416880; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=utt30JAJTgovEUnU7oZUHBSJjF7rzQywZWScCNuHRzY=; b=6HYx2XpnQKbqjzV07aQ/q6tpsTDoS3IzK60QfBzd/6pvoc5YbEtmJQULZ2tCnnMNv7dcbs uJte24DxRKkDQ994qdMXg2jSpb0Umze14qEVdpbys84EU41J4z464qFPfLg4bVyjGOSrJC OMNazaYxGPe+2rP3ii1Snw0fC2K05q4= X-Stat-Signature: ozizp1bkcxgyr4b9uhi6aodew7occwjq X-Rspamd-Queue-Id: C259780006 Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=WPA3CheU; spf=none (imf02.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-Rspamd-Server: rspam03 X-Rspam-User: X-HE-Tag: 1667416878-455360 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, Nov 02, 2022 at 03:02:35PM -0400, Peter Xu wrote: > Does the patch attached look reasonable to you? Mmm, no. If the page is in the swap cache, this will be "true". > diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c > index 3d0fef3980b3..650ab6cfd5f4 100644 > --- a/mm/userfaultfd.c > +++ b/mm/userfaultfd.c > @@ -64,7 +64,7 @@ int mfill_atomic_install_pte(struct mm_struct *dst_mm, pmd_t *dst_pmd, > pte_t _dst_pte, *dst_pte; > bool writable = dst_vma->vm_flags & VM_WRITE; > bool vm_shared = dst_vma->vm_flags & VM_SHARED; > - bool page_in_cache = page->mapping; > + bool page_in_cache = page_mapping(page); We could do: struct page *head = compound_head(page); bool page_in_cache = head->mapping && !PageMappingFlags(head);