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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C63EC433FE for ; Wed, 2 Nov 2022 19:21:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230518AbiKBTVZ (ORCPT ); Wed, 2 Nov 2022 15:21:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbiKBTVW (ORCPT ); Wed, 2 Nov 2022 15:21:22 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAF811144; Wed, 2 Nov 2022 12:21:20 -0700 (PDT) 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: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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);