Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2576507pxb; Tue, 13 Apr 2021 05:27:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0SXml4iByUd+t87528qm+SzZG+Q3bmAKe8M0O2NrOkzrtIg51oTa9XFK841+AbmIffS5I X-Received: by 2002:a17:907:720a:: with SMTP id dr10mr31648055ejc.375.1618316837807; Tue, 13 Apr 2021 05:27:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618316837; cv=none; d=google.com; s=arc-20160816; b=y1HXPSACd5hTTQ/eM91spbAp57VgnJNAJ9kfAeOG0JDgY1Djb8OLRbwHu1BR/VJO1c WlAR9WR3RAh2JKU8FAw6I4TQPIPsZ6hs8fDuD/pFubYD8luHsuWGrVyOdzs+87ln7PG3 QtWp24dvkHDVfwUTNjH4S0S72a4GqlGp6JX3/rOGlkVY/2Og9SPAhTemjHpgOLbq3uRH Av3kdyOUzeiO4Kx06g8LbX1e6h++BXuW5bTe1fBhR/2t42OfDy8XoYo0mmkuI6zAj9fT rKz6s+6TBrBxBT6wawG8Knzlx4xd37KeoLpFGgOh478Sqt9SpVHqznvVqTHXdvVBLlV4 BBaw== 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=fk8f62xjqnl3mv3ljyxxc5ev3FlVYq11HMKlMY+I2mI=; b=FVHzXrHHZK4tBmucURB+iwAPANua0C15tX8BkgOOFkWsdhYtbWv7aSlLh+LlqLW+mU Ez4Nvzggn1RVwSal1GuNz0bef4R8WhIlfQMvkyQKD2E9PKLbCJmwK1Ik5k/2cK4s7I/U cIJPc8ouvislkA6h140izIS/bUIamhC1bQ2tWhUJd8fmdUY497TRVIWmftpCE6Kws351 UYXVJ/oR7nhqshSHPf4wYxlbsmohxkqLG9XsQCFlDzPfMiWY9QXOANF1fmN9kieZC2ek BzlHbJvcY3am4nOj4aXXQ7BCmP7L38XxGAT04mtdh3mKVUOUFtGxIqSXjsQrQ6yULDfk JD/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bKMDXmtQ; 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 n17si9821817edo.522.2021.04.13.05.26.53; Tue, 13 Apr 2021 05:27:17 -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=bKMDXmtQ; 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 S238344AbhDLX6R (ORCPT + 99 others); Mon, 12 Apr 2021 19:58:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:40362 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238263AbhDLX6Q (ORCPT ); Mon, 12 Apr 2021 19:58:16 -0400 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-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-255-eJyiahxuOPesDHetXcU52A-1; Mon, 12 Apr 2021 19:57:55 -0400 X-MC-Unique: eJyiahxuOPesDHetXcU52A-1 Received: by mail-qt1-f198.google.com with SMTP id h26so209117qtm.13 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=AZlgiP3iiIDwl5B+AdVqHTPWbaj8vTEI8CJEz5RZ8dnT+vMDjnyJS4KrsSbTE3RPmu //D9oO7novIuqQIYOrRM44OXAsOdwhx6JfKCUTjsiFAYOysKjY0X6BdObEEv02McSHqq 0aWsfRknWVUvmYIEzDypKJ8sbS8WyNKO4BRsVYZfRKDqlOt20VH7PWckUDwQXjVFqWsI ASFREHIkc4aYiGtdKrG1I1wQhgaSimRbtPeh/6j7DFurmL0ByXZTHAIzjpGfDKiBEqxg rfLS6tm/IVGVWTe9+310tDk5GageXjwgPOhdRNOogweGQO/x2t5KqnJRZYg8Q1rbQbzu a5Ig== X-Gm-Message-State: AOAM5319EG8VbUtBH15JNZufGZT9M7NrQV7Ji90raED+7dMcqIihw2r0 T68QJdOCASkMP0OruZ5+v+arJyJXygc/JBFtEyY+hjAMYF0eWhY/ckQIPqva5yPjlFLeI7uhaAk DM9Ufeeuz64c+G4Osubwxee/q X-Received: by 2002:ac8:5bd0:: with SMTP id b16mr27256746qtb.265.1618271875253; Mon, 12 Apr 2021 16:57:55 -0700 (PDT) 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 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210408234327.624367-3-axelrasmussen@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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