Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp819664pxy; Thu, 22 Apr 2021 14:20:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwY9VmUlwZONtti6dVNfb/NdDH1WWlQs63AkDgTrPN8HPAK/prFXM8Mx6eXhTtnR8WYhZxR X-Received: by 2002:a62:6481:0:b029:249:ecee:a05d with SMTP id y123-20020a6264810000b0290249eceea05dmr599091pfb.9.1619126424729; Thu, 22 Apr 2021 14:20:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619126424; cv=none; d=google.com; s=arc-20160816; b=Ld3my6hjMaTLU3lymgCPrayKAjQxeoGZDZZWQvWiNrBPtDwG0zgz50tM/eCrTc6yQt GKSAdlzRFq9b/oSpcGPj1UF27HH8w/6QrUjgl+aNxnq8x5snXvPeQKvGFxCdblVMwVhv qtxBsfL1Ad0WQ0ehgKbXuLKNggXQ2GDZ0ZG/3nUbNrB3StxAK/s9C6q830HIgrwq7JR7 R3VasSx1CQqhG7zHPmSXsqVNEwpJS4RmfzGSJsegwnx7FUcLf1XB+Tu2za3fB790grAc rn+WHYnEHD1WnH50+Qo14WWa5jhu1MnAKWuTC7MU6yJ3S/XnoiQQONo1OF76yPB/163F Uy1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=WL2DjbQuTq/EcUdymB75wSg7jJRF6qAH0Wk/CKq5EIY=; b=rUL2dPr368CJi1MZwQ48snMG/fdqfybkCipRhg4GdDSTjzu7WfTkZfqO+149nLJhuA v9FrcOnQl7YKPD4r9F0kx9xMHP2lJpMkqKbwgAmil4xQ0fx+Fevk0eVjXLjOwHQJOFNv ojISa2tzjF7GNGuxo2Dsrao8m5eHMzFhguv55umGp2yn2/CLjA5GUyLrjfreVtlKZYhJ tXD7nftrfYmMO0FSb9pZJxkL01gqq1jm+pO1LCATDpzTJ1ve3K/tyB/zLWQRu9ahRxKj bbmXO0zAi4PfKYuqkkvxtZh7E/eG21mvn/WXO2tQVQ/QhFsAfi7b/Msu9+nY9i+f6K72 9s6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NaVMIVqi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d23si4488300pls.298.2021.04.22.14.20.00; Thu, 22 Apr 2021 14:20:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NaVMIVqi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239195AbhDVVTb (ORCPT + 99 others); Thu, 22 Apr 2021 17:19:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:26378 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239028AbhDVVT3 (ORCPT ); Thu, 22 Apr 2021 17:19:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619126333; 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: in-reply-to:in-reply-to:references:references; bh=WL2DjbQuTq/EcUdymB75wSg7jJRF6qAH0Wk/CKq5EIY=; b=NaVMIVqip12907fMyjNg1oofPerixidc38we8+ysPVLusmnIkVC6dOHjhwQmtg20sVEomZ fZRNvoSR+A7zismXSnUhonSTTab9sMGtBW5MZRg1ymMMqMXiUeqRnUyQI6Pn9PmOgbF5Of hwpUCWvaLuKO2pXqp1+Weezj3n3luQY= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-511--gu7ZoZ1PdOQL69Q3TCMBw-1; Thu, 22 Apr 2021 17:18:51 -0400 X-MC-Unique: -gu7ZoZ1PdOQL69Q3TCMBw-1 Received: by mail-qv1-f71.google.com with SMTP id y14-20020a0cf14e0000b029019ff951fd16so15799351qvl.12 for ; Thu, 22 Apr 2021 14:18:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=WL2DjbQuTq/EcUdymB75wSg7jJRF6qAH0Wk/CKq5EIY=; b=DDRQjK6zXYFB4xVpxWdgCx44GrQHGew136l6tjs9/SmUIAF6Uif8hxHowHVTggb572 G68JH0ks71AZ/rPbQKLfhrUOPtZstWmZxMQP4elbHx0XIo4B0viczc7WLcAPR4YAfBtk lc1k7Yygtk7qn7neaYpTa1Gi1Wb4lMO9C0HobJ5g3ElpJW/lHUU5PX1Dm1DqcFzN6jVd aYTJ1wawYcHn5rc0BZ3ot8gP6cdrwYdRnNamSBZbpvrXKAiZkDjNA4FeuHgHzuiP9JgJ NolfplXbFbBRNjAxPmxUzUaqp+MqhoTOQPH7xeaPfoFsoQKe1wG5W3lwfBqNjxr9HMqQ OYPQ== X-Gm-Message-State: AOAM531hKWZQT6CN3gbitJ59C3xPYr2A1+fY9HXcXISfdXK4MWOynKcm /zSZQj6Yg/IlfHCjCpcR9ZyBLs9HQeo5iAnqE3yHzjSgxWQWV+5Q9MJh9yPpvjbaeLXYDl4wzw3 ZVnuiYk7ttuUh3bwZceq1d52S X-Received: by 2002:ac8:4793:: with SMTP id k19mr453047qtq.373.1619126330844; Thu, 22 Apr 2021 14:18:50 -0700 (PDT) X-Received: by 2002:ac8:4793:: with SMTP id k19mr453015qtq.373.1619126330602; Thu, 22 Apr 2021 14:18:50 -0700 (PDT) Received: from xz-x1 (bras-base-toroon474qw-grc-77-184-145-104-227.dsl.bell.ca. [184.145.104.227]) by smtp.gmail.com with ESMTPSA id g135sm3084697qke.8.2021.04.22.14.18.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Apr 2021 14:18:49 -0700 (PDT) Date: Thu, 22 Apr 2021 17:18:47 -0400 From: Peter Xu To: Axel Rasmussen Cc: Alexander Viro , Andrea Arcangeli , Andrew Morton , Hugh Dickins , Jerome Glisse , Joe Perches , Lokesh Gidra , Mike Kravetz , Mike Rapoport , Shaohua Li , Shuah Khan , Stephen Rothwell , Wang Qing , linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org, LKML , linux-kselftest@vger.kernel.org, Linux MM , Brian Geffon , "Dr . David Alan Gilbert" , Mina Almasry , Oliver Upton Subject: Re: [PATCH v4 03/10] userfaultfd/shmem: support UFFDIO_CONTINUE for shmem Message-ID: <20210422211847.GF6404@xz-x1> References: <20210420220804.486803-1-axelrasmussen@google.com> <20210420220804.486803-4-axelrasmussen@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Axel, On Thu, Apr 22, 2021 at 01:22:02PM -0700, Axel Rasmussen wrote: > > + if (page_in_cache) > > + page_add_file_rmap(page, false); > > + else > > + page_add_new_anon_rmap(page, dst_vma, dst_addr, false); > > + > > + /* > > + * Must happen after rmap, as mm_counter() checks mapping (via > > + * PageAnon()), which is set by __page_set_anon_rmap(). > > + */ > > + inc_mm_counter(dst_mm, mm_counter(page)); > > Actually, I've noticed that this is still slightly incorrect. > > As Hugh pointed out, this works for the anon case, because > page_add_new_anon_rmap() sets page->mapping. > > But for the page_in_cache case, it doesn't work: unlike its anon > counterpart, page_add_file_rmap() *does not* set page->mapping. If it's already in the page cache, shouldn't it be set already in e.g. one previous call to shmem_add_to_page_cache()? Thanks, -- Peter Xu