Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp62943pxy; Tue, 4 May 2021 18:36:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqvVN56r4TS0uDjKl0kpPtxAnD2LkMpXRNIp/KhXjDPTeBmVMsWVn+buno+tfJSGn45Rof X-Received: by 2002:a63:e712:: with SMTP id b18mr26272740pgi.2.1620178579024; Tue, 04 May 2021 18:36:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620178579; cv=none; d=google.com; s=arc-20160816; b=lLY9vX9aKSYuuYxibrIK4RmlWFYmhkNle9Ze4ImprqYu09aaR5QR6xg/kM7UarSsP9 B5B66z8qEOVR2cGbREu9QUrUyCaBSnfaAtIWS1hKwWxOv70gNrusjZvkDcz4KsoRXbMy elIB9zshUkW/ynILeaqnvrEK0s8X4VXHd0pbiuny/1nXP4R4YtpaDYOIVfzMN/0ishmu iyr9OJaiNqMTTxq4SbnxfxrgEtrLy8TZaQnbJtoEN3PygLgGlsjdoc3L3XXjQ2UPZLiV gUx6GyZmvvwcirtrolEFjTiXuO3vnsVdKY2t69ypqXgahymC3h6w12i61xXry1qjkGby 9hRw== 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=cPRVInBsTWC+0BUGJOB5FIDSOa450b+bMYREaXrrpp0=; b=MVXlzS5pLYspX+hsUQIr0g4Yxlmpfz18FgShzrPVA0T3ww9sLTJw8HAAqxpo71UHuR 3INQh4ue1JweP808S33qoi0e/KWzqlHUUrc1vlHNBiYX9ZXdU2rbuMomdTzSrfNMcG7Z 2N/qatnaqxbyvFXpoqjdAd+F1G63QNKk52QuRtuPeoZcitJYoYCJ25MIpNKVixjjDjMQ dwVSSSwP8SG47WUPI1vujhJC9h2qeTk+Mk2yg4hvbfHFEvm84dQATkMXrqrD6GMIdVP2 LNtaPfJvs1Y+cm5m+qGNAG1oUN24J/aatstg9n97UovPjJQVt+qtKAoZifJDuKhKGp2v sL7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OlYvEWST; 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 b2si5528513pjn.42.2021.05.04.18.36.06; Tue, 04 May 2021 18:36:19 -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=OlYvEWST; 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 S229985AbhEEBdG (ORCPT + 99 others); Tue, 4 May 2021 21:33:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:54236 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229799AbhEEBdF (ORCPT ); Tue, 4 May 2021 21:33:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620178329; 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=OlYvEWSTM0YyKkoXTzEv61TTW5NH29xkBb25yX96IdN3aG9PrrU2hvknfbG6XXm+bQOf2c Ydgxw90FsbUxZw22G0if2eT97Ki9tbZA1X9pAGTsT7fMc7Ngv9HgTVQI2w+2QZPJ5qCsq5 xwP45KTF153RAvYc5VGcsGm8xQ1bxQM= Received: from mail-io1-f70.google.com (mail-io1-f70.google.com [209.85.166.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-118-EceD1YoQPVWHco1GNjnZxw-1; Tue, 04 May 2021 21:32:08 -0400 X-MC-Unique: EceD1YoQPVWHco1GNjnZxw-1 Received: by mail-io1-f70.google.com with SMTP id i204-20020a6bb8d50000b02903f266b8e1c5so162486iof.16 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=AOe8QpxpUsKQcfdrsLikEmDaJIcAkTsLOgRQy3XPkUggwvNcBfGWPadodYoW8JpNJc HQ5dkW5uVUvudIeQcDYtoXoN1iykKHmf3cSf3lhG2YxTO2zyUo0HDb1uijCQc1+WoE+y hl5suN97xlHT5z1J5RWDfnlpsRQbyKtEIbIXg9Xn+CN6R8jWtYX8HHRAoA3Fw7kusYUk TdTtQeZpSDFPN3vqJbqXC4TxXYFFgKIZapRQCUlPp8l/ThiGX3+ZaKyC4ZQ7QqSujUCc 9AinSlE4g1/nNkyBYQ+j6KmvjZ6EoiTodnsuf/+SsVfwWaiSRCy8vkejEk8Zu3f5PuzM G+Lw== X-Gm-Message-State: AOAM533wiUCWyFvuZt6jr+Y8uI5957A+QQwKXs+7cMgCZ+GttNzMSiGl AkiKIB9ZJ4KJgxqXMouOF2O3ZxaeNhwzWu1/a4k7GX2N5bJ9xw3AmiKHMQg/9Ymzcvcg5FW1oid Nh15lZgyobdp5yfc5QOntsI5C X-Received: by 2002:a92:8e03:: with SMTP id c3mr2036560ild.167.1620178327564; Tue, 04 May 2021 18:32:07 -0700 (PDT) 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 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210503180737.2487560-7-axelrasmussen@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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