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 X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2660C43460 for ; Mon, 12 Apr 2021 23:57:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 486D961369 for ; Mon, 12 Apr 2021 23:57:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 486D961369 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CEC506B0036; Mon, 12 Apr 2021 19:57:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CC2A36B006E; Mon, 12 Apr 2021 19:57:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B14CF6B0070; Mon, 12 Apr 2021 19:57:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0100.hostedemail.com [216.40.44.100]) by kanga.kvack.org (Postfix) with ESMTP id 92CB06B0036 for ; Mon, 12 Apr 2021 19:57:58 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 51D8F6D62 for ; Mon, 12 Apr 2021 23:57:58 +0000 (UTC) X-FDA: 78025380636.05.1B43666 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf29.hostedemail.com (Postfix) with ESMTP id 117C7E4 for ; Mon, 12 Apr 2021 23:57:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618271877; 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=fk8f62xjqnl3mv3ljyxxc5ev3FlVYq11HMKlMY+I2mI=; b=bKMDXmtQUNLwEAPA+/Iw8zheAt0uvZRDnTX/sIbCVDPuh8U4KUWlL/VcaHpxW+UBw8wpIm IrEmpiat3SlzrUj8KxljfurZbZetD/jDX5p4D0xhaW4d6uCeFB9Io/WAlYwbh6wzCjDh+l DNYbIKDH4AAnJgxZVJIBvZYQ2eWtpYg= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-455-s0Z4syD3OPOv-4H7bbkQ4A-1; Mon, 12 Apr 2021 19:57:55 -0400 X-MC-Unique: s0Z4syD3OPOv-4H7bbkQ4A-1 Received: by mail-qk1-f198.google.com with SMTP id 14so9326298qkf.0 for ; Mon, 12 Apr 2021 16:57:55 -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=fk8f62xjqnl3mv3ljyxxc5ev3FlVYq11HMKlMY+I2mI=; b=BrGICPIex8d8zVSqU028e5errYj0W59YA6K547nZglmaHednGLm1GzVLXwRe7ittmt ffOQcy2gBtP+kY/zCVUd23Er2jSJxoa4ITWFX1yxwoV3ctcEK5s1yk3ob/ECJ0LMtK3S Zz/RErG8uaaOekZ6gw2YqyFaAEruMZeiVklPmXcCA7lSmA1aczIITrrt7g7jN4J8iQd5 xR+NWq7nOTvQjbFj0xiUl+kOyRBR9pjeGnAe4FsL2JlOytbKnZM0N2OUnOuOLMlsLuGV 1WJfMaphTXWkt4wRGk8MFXwIzJlpHlb6/moph6aq5XzP7jA7Zj2l1SuXe7ifFL9CnIxm 7qEA== X-Gm-Message-State: AOAM533kQMD+DUGiujsPkspzYBpvOlp8N7gHipIrj712VFf/W/zam+x8 Wxd2FS+jW8XFEqrwcayi00nv+26vGdWXMj7FxP+JbawQ3bKUp4GOQPQVcee9VbWh8r2ApR7d3pH sDVKGtZaU9PA= X-Received: by 2002:ac8:5bd0:: with SMTP id b16mr27256748qtb.265.1618271875254; Mon, 12 Apr 2021 16:57:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyINLu5vRRG0SiDZ5ReSE5VIP4sHwe9BnqH3/WUUNCWDJZ4MX4YNqZ5FmXfacMqWYulpB87ZQ== X-Received: by 2002:ac8:5bd0:: with SMTP id b16mr27256724qtb.265.1618271875002; Mon, 12 Apr 2021 16:57:55 -0700 (PDT) Received: from xz-x1 (bras-base-toroon474qw-grc-88-174-93-75-154.dsl.bell.ca. [174.93.75.154]) by smtp.gmail.com with ESMTPSA id n6sm8421251qtx.22.2021.04.12.16.57.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Apr 2021 16:57:54 -0700 (PDT) Date: Mon, 12 Apr 2021 19:57:52 -0400 From: Peter Xu To: Axel Rasmussen Cc: Alexander Viro , Andrea Arcangeli , Andrew Morton , Daniel Colascione , 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, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, Brian Geffon , "Dr . David Alan Gilbert" , Mina Almasry , Oliver Upton Subject: Re: [PATCH 2/9] userfaultfd/shmem: combine shmem_{mcopy_atomic,mfill_zeropage}_pte Message-ID: <20210412235752.GC1002612@xz-x1> References: <20210408234327.624367-1-axelrasmussen@google.com> <20210408234327.624367-3-axelrasmussen@google.com> MIME-Version: 1.0 In-Reply-To: <20210408234327.624367-3-axelrasmussen@google.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Stat-Signature: n119bq9jszjy6oacgr5eaiqmx57fdz6b X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 117C7E4 Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf29; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=216.205.24.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1618271875-89939 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 Thu, Apr 08, 2021 at 04:43:20PM -0700, Axel Rasmussen wrote: > Previously, we did a dance where we had one calling path in > userfaultfd.c (mfill_atomic_pte), but then we split it into two in > shmem_fs.h (shmem_{mcopy_atomic,mfill_zeropage}_pte), and then rejoined > into a single shared function in shmem.c (shmem_mfill_atomic_pte). > > This is all a bit overly complex. Just call the single combined shmem > function directly, allowing us to clean up various branches, > boilerplate, etc. > > While we're touching this function, two other small cleanup changes: > - offset is equivalent to pgoff, so we can get rid of offset entirely. > - Split two VM_BUG_ON cases into two statements. This means the line > number reported when the BUG is hit specifies exactly which condition > was true. (For my own preference, I'll avoid touching the latter one) > > Signed-off-by: Axel Rasmussen > --- > include/linux/shmem_fs.h | 15 +++++------- > mm/shmem.c | 52 +++++++++++++--------------------------- > mm/userfaultfd.c | 10 +++----- > 3 files changed, 25 insertions(+), 52 deletions(-) > > diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h > index d82b6f396588..919e36671fe6 100644 > --- a/include/linux/shmem_fs.h > +++ b/include/linux/shmem_fs.h > @@ -122,21 +122,18 @@ static inline bool shmem_file(struct file *file) > extern bool shmem_charge(struct inode *inode, long pages); > extern void shmem_uncharge(struct inode *inode, long pages); > > +#ifdef CONFIG_USERFAULTFD > #ifdef CONFIG_SHMEM > extern int shmem_mcopy_atomic_pte(struct mm_struct *dst_mm, pmd_t *dst_pmd, > struct vm_area_struct *dst_vma, > unsigned long dst_addr, > unsigned long src_addr, Not a problem of your patch, but it's just that we passed in odd src_addr values into mfill_atomic_pte() for zeropage case because we loop on src_addr in __mcopy_atomic()... Then it'll further passed into shmem_mcopy_atomic_pte() now after this patch (as shmem_mfill_zeropage_pte() probably only did one thing good which is to clear src_addr). Not a big deal, though. All the rest looks sane to me. Reviewed-by: Peter Xu I'll wait to look at the selftests since in all cases they should be prone to rebase (either based on the v2 cleanup I posted, or you'd need to post without err() - then I can rebase again), so I figured maybe I just read the new version. Thanks, -- Peter Xu