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 A3CC0C433F5 for ; Wed, 12 Jan 2022 05:02:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EE11F6B011E; Wed, 12 Jan 2022 00:02:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E8F906B011F; Wed, 12 Jan 2022 00:02:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D80046B0120; Wed, 12 Jan 2022 00:02:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0236.hostedemail.com [216.40.44.236]) by kanga.kvack.org (Postfix) with ESMTP id CA7426B011E for ; Wed, 12 Jan 2022 00:02:49 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 6A102944E8 for ; Wed, 12 Jan 2022 05:02:49 +0000 (UTC) X-FDA: 79020440058.04.A582CC2 Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) by imf23.hostedemail.com (Postfix) with ESMTP id 048AE14000C for ; Wed, 12 Jan 2022 05:02:48 +0000 (UTC) Received: by mail-qv1-f51.google.com with SMTP id jr5so1696121qvb.11 for ; Tue, 11 Jan 2022 21:02:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:in-reply-to:message-id:references :mime-version; bh=KFpreeJOa09J1P7gf+hNJT3B4ZftF/zoJ3KRQCsPlho=; b=dIiVlGHbDok+X9s/PRCVB6Le+sratTCI0QwBWS7FwNTnNfSoNx0QZey6wtG+BXwY/E QczVy3mCSI0piwZShY3ZcVUZsGtLOgqfprfGfpAwuHjpUJ3HiqJzYSLzgnoK5c8DV7WS 2khZAllAvWZZCsp5iqxGCyY52JF9rq8w0JqfrXzISpHgdNH8tmE+2nW7R4NQwkNZe1Ma XPUcex/WCTOYh/CHASd2HwnGnaj1QMSQ3safUVTnxKfuI5bOQ+OoyXPqh05zzeMu2Jqd i6ivLGrmtTeNmcunngr8vOsOYCKw4rT7NE8SQxhwaq9VQqmzgki53ehdzUc1PQmqzByE IcXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:mime-version; bh=KFpreeJOa09J1P7gf+hNJT3B4ZftF/zoJ3KRQCsPlho=; b=e/q9tS+X/yz3kq4syPKfTXK/ryD+bf5sRC4poPWkqlgErNrc31ahNhQgfshSrySO+w ff+Grllbgzar8reiRKBMI8QCHLgN33xu+Fitcpf0BMDFZo0g4Yf90/npuNaBKDUD8IW9 tIen+yvTGQpujJkGeZY2ibqBKTSWcdfi86+x1MTq0rA7wbTcHxjsrW3U1v+LZRfLH4w2 8sM/8n39eqMZOrXQLbG4x9EebsGvwFHr/bXV51i71oXaMo4RTVY6wiVsTNM8gxkS18P/ +2khuNuoUqvvKLr+kQg27S7RHvLsCmy5r+0+SUmBgXeaw7Lddv4twWRt7ix2uCYAoKAD DIqg== X-Gm-Message-State: AOAM533xdQfbD/QN+JGQEbobcBRXAiRck/2UgTBPb6lk0rnaQK9MIefR j0KzVoFa7LuR/u3m8Ybv1L/LJQ== X-Google-Smtp-Source: ABdhPJwDc/NA9+I44clTwhOqDnbPfHIMXSZmMJ123HgmVJsI8rz3BzUH6xKNeXXt/7sENuW0Twf4Ww== X-Received: by 2002:a05:6214:d45:: with SMTP id 5mr6663620qvr.66.1641963767989; Tue, 11 Jan 2022 21:02:47 -0800 (PST) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id t6sm7967728qkj.33.2022.01.11.21.02.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jan 2022 21:02:47 -0800 (PST) Date: Tue, 11 Jan 2022 21:02:45 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@ripple.anvils To: Yang Shi cc: Hugh Dickins , Peng Liang , David Hildenbrand , Linux MM , Linux Kernel Mailing List , Andrew Morton , xiexiangyou@huawei.com, zhengchuan@huawei.com, wanghao232@huawei.com Subject: Re: [RFC 0/1] memfd: Support mapping to zero page on reading In-Reply-To: Message-ID: <9e96fc57-6810-9efd-c1fc-4c8a54b125@google.com> References: <20211222123400.1659635-1-liangpeng10@huawei.com> <4b1885b8-eb95-c50-2965-11e7c8efbf36@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 048AE14000C X-Stat-Signature: aa79b4q4b8p1fmk458edmiwkr91sxodp Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=dIiVlGHb; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf23.hostedemail.com: domain of hughd@google.com designates 209.85.219.51 as permitted sender) smtp.mailfrom=hughd@google.com X-HE-Tag: 1641963768-882312 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 Tue, 11 Jan 2022, Yang Shi wrote: > On Tue, Jan 11, 2022 at 6:30 PM Hugh Dickins wrote: > > > > But I have to say that use of ZERO_PAGE for shmem/memfd/tmpfs read-fault > > might (potentially) be very welcome. Not as some MFD_ZEROPAGE special > > case, but as how it would always work. Deleting the shmem_recalc_inode() > > cruft, which is there to correct accounting for the unmodified read-only > > pages, after page reclaim has got around to freeing them later. > > I'm wondering if we could use ZERO_PAGE for shmem_getpage() too so > that we have simpler return value? Currently shmem_getpage() returns: > #1. errno and NULL *pagep > #2. 0 and valid *pagep > #3. 0 and NULL *pagep if SGP_READ > > Using ZERO_PAGE should be able to consolidate #2 and #3 so that we > know there must be valid *pagep if 0 is returned. At an earlier stage of mm/shmem.c's life, shmem_getpage() did return ZERO_PAGE rather than NULL for that case; but I found it works out better the way it is now (despite I'm not a fan of *pagep generally). So I've no zest for messing with that now - though it's possible that if we did extend the use of ZERO_PAGE, I'd look again and decide that your change is then the best. One reason for NULL rather than ZERO_PAGE was actually to help avoid the cache-dirtying get_page/put_page on the thing; but that appears to have gone missing at some point. I have a patch in my tree which fixes that, but held back from sending it in because it also used iov_iter_zero() instead of copy_page_to_iter(). Obviously a good improvement... except that whenever I timed it I found the opposite. So, set aside on a shelf, to look into some other time. > This should make read-fault use ZERO_PAGE automatically. But I don't want to make read-fault use ZERO_PAGE automatically: I want to be rather careful about that change! Hugh