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=-11.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,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 42123C433B4 for ; Wed, 5 May 2021 01:32:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EADED613CC for ; Wed, 5 May 2021 01:32:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EADED613CC 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 6F1398D0006; Tue, 4 May 2021 21:32:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6A1558D0003; Tue, 4 May 2021 21:32:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5428B8D0006; Tue, 4 May 2021 21:32:11 -0400 (EDT) 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 39C278D0003 for ; Tue, 4 May 2021 21:32:11 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id E69EF8777 for ; Wed, 5 May 2021 01:32:10 +0000 (UTC) X-FDA: 78105451620.29.601ED8E Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf05.hostedemail.com (Postfix) with ESMTP id 51950E000111 for ; Wed, 5 May 2021 01:32:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620178330; 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=cPRVInBsTWC+0BUGJOB5FIDSOa450b+bMYREaXrrpp0=; b=RPi+LzQ5BM+t1GpveXBRNbwChSu0fL3JyyOv3/nQFxjx6g71+Nqkjm/drsa6mSFR4lLCvm ocqaas50O0ZTaqquk10lviSIgjOQgvYKGhHjh5ARYcNpqiwWJb0v+nPFylGqTe6g38jw6s eojA8oQzjTjvrMgsTgCcS3HgeA2hbq8= Received: from mail-io1-f69.google.com (mail-io1-f69.google.com [209.85.166.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-227-2ShFlwVlMvuv8yBvGC4QIg-1; Tue, 04 May 2021 21:32:08 -0400 X-MC-Unique: 2ShFlwVlMvuv8yBvGC4QIg-1 Received: by mail-io1-f69.google.com with SMTP id y15-20020a5d9b0f0000b02903e840cb5f09so169745ion.12 for ; Tue, 04 May 2021 18:32:08 -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=cPRVInBsTWC+0BUGJOB5FIDSOa450b+bMYREaXrrpp0=; b=fyLx2caNLHtWYvtoMlh+Qo/fW20twq/3Uqp/DOuHqp3GLDdqEsk/qSInbyugy2kByV M1bUfJgn0KlsepP2GTOxePyiU72yzD24jJU72sEUTw4qyoX1zs3UrzUlVOKE7ZTVlJf2 apPIQjmoVEvAmfKqRdaU0vsnX+NnMZFs7YoLUxrrS+Tl+1G6YoPo2Wmxjx+pnKb1bdWA EBEBZSoIAQKPdw5sE//+zv4SlqOsgAyBs5RgPb7HE8w9LGjbpkXT6M2J0asN79JKiwev Lqmv8uHtdFXXzdVuvDqSjoM0OE1hD5iSjV22bfEUswHiXmJBo1ENG7IFiIpMl5Kqj9pe mosA== X-Gm-Message-State: AOAM533laM43NDWoI/kZMuXWPB7HLCkHlLM1XmGXVklPWNg2ao8ekdnB sJ0/sg/lzB8/0nyaXvtyTlcjsaZCBOQeyLeYXpvF5rKRv+mub5zGQBzHChADIDJ8CCgQgM1nnnG 0Y9zlT+j3mVc= X-Received: by 2002:a92:8e03:: with SMTP id c3mr2036568ild.167.1620178327565; Tue, 04 May 2021 18:32:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNg9jcG4O9OkPZqQlTS7aeMFQ7/soHNplo9cjmrJ2Ghe+p949bqg4pbzePUCrb/19N4cHmHg== X-Received: by 2002:a92:8e03:: with SMTP id c3mr2036544ild.167.1620178327359; Tue, 04 May 2021 18:32:07 -0700 (PDT) Received: from t490s (bras-base-toroon474qw-grc-72-184-145-4-219.dsl.bell.ca. [184.145.4.219]) by smtp.gmail.com with ESMTPSA id u9sm1842495ior.8.2021.05.04.18.32.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 May 2021 18:32:06 -0700 (PDT) Date: Tue, 4 May 2021 21:32:04 -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, 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 v6 06/10] userfaultfd/shmem: modify shmem_mfill_atomic_pte to use install_pte() Message-ID: References: <20210503180737.2487560-1-axelrasmussen@google.com> <20210503180737.2487560-7-axelrasmussen@google.com> MIME-Version: 1.0 In-Reply-To: <20210503180737.2487560-7-axelrasmussen@google.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=RPi+LzQ5; spf=none (imf05.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 51950E000111 X-Stat-Signature: 8q8sg9x148o9zjezgzrecmbafdm75xfg Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf05; 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: 1620178326-525432 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: Axel, On Mon, May 03, 2021 at 11:07:33AM -0700, Axel Rasmussen wrote: > In a previous commit, we added the mfill_atomic_install_pte() helper. > This helper does the job of setting up PTEs for an existing page, to map > it into a given VMA. It deals with both the anon and shmem cases, as > well as the shared and private cases. > > In other words, shmem_mfill_atomic_pte() duplicates a case it already > handles. So, expose it, and let shmem_mfill_atomic_pte() use it > directly, to reduce code duplication. > > This requires that we refactor shmem_mfill_atomic_pte() a bit: > > Instead of doing accounting (shmem_recalc_inode() et al) part-way > through the PTE setup, do it afterward. This frees up > mfill_atomic_install_pte() from having to care about this accounting, > and means we don't need to e.g. shmem_uncharge() in the error path. > > A side effect is this switches shmem_mfill_atomic_pte() to use > lru_cache_add_inactive_or_unevictable() instead of just lru_cache_add(). > This wrapper does some extra accounting in an exceptional case, if > appropriate, so it's actually the more correct thing to use. > > Signed-off-by: Axel Rasmussen (The moving of "ret = -ENOMEM" seems unnecessary, but not a big deal I think) Reviewed-by: Peter Xu Thanks, -- Peter Xu