From patchwork Wed Nov 16 10:26:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 20900 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp68096wru; Wed, 16 Nov 2022 02:39:28 -0800 (PST) X-Google-Smtp-Source: AA0mqf7CBoJ/mxdgQEDkDLpFVKalmqmE1UK4rbD1cRnmIZA3Ute4dYtN3B50sukVORXHJnJrnPsX X-Received: by 2002:a17:906:e283:b0:78d:addf:67c3 with SMTP id gg3-20020a170906e28300b0078daddf67c3mr16805597ejb.253.1668595168072; Wed, 16 Nov 2022 02:39:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668595168; cv=none; d=google.com; s=arc-20160816; b=wMd60BTuhefqBrBh90R1AOEbywjalCeHysRgICC4BHyQF3XI5JldvvYjhcOEfxwKpt rZqb6Yx4+AE8Dzkl7ROzc1yC984ZEwBqD14j+sLBtlDFFsybGJQGTDEtjzjrr7Bb756D 9uwjihEtY3q9JRbdXhKRh7wZy1F+OFX1vmP6fx2UioPuA+KqZwH5105no7Cop+iKylw3 AQPdNSRAzZ0DrysCNXqBdKRiHH7f7+7YAKC2ztRvGa3Kysp3sj9vxvzatapmybDe8yNZ 2I1NCYwQ7UCa4CN1g9i1bm+0XJSGtQ9ehzHTwHjYHgEY1GJnrUDMvgrM3Ruv6EPHv2m8 yJFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xyj8jS+C9wqOk3KceDQTo75wMiWZgljnGSBlM8HQloY=; b=EVjws5aYIMhY2SES92xKUDc+tBT8PpNn49pBvT4p1w1NxY/x5DRxtlfnB8LuLIqefx kxWqgVPdGpnlsCT/0ARJPa3l0ojC6tnR3vHzNnFV1gFqYoBFUU0vRqhhRhjYtITAnrwh zLuVBG9ZpfEbH8TOMxtJ6t4XuFcMuH6M0ZJPN+bqGC5b8irreL6PITmxQa5B+/iO2LAz AyRi047maB6XhU508AcESvQXkdK6yLnd8xrWDz+h/75kNy0fOUqLQUSDswTkjxQd0s9V /vj8JF8777OoM8gjv5NyOXxvBVjTazczJIVvVromL1k4E7IRt8FWeX+vrryKCLVdw0mO qD+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZuuZEBvW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i22-20020a1709061cd600b007ae24f28400si11361113ejh.247.2022.11.16.02.39.04; Wed, 16 Nov 2022 02:39:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZuuZEBvW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S237967AbiKPKhY (ORCPT + 99 others); Wed, 16 Nov 2022 05:37:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232881AbiKPKfo (ORCPT ); Wed, 16 Nov 2022 05:35:44 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 365B0FD05 for ; Wed, 16 Nov 2022 02:28:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668594523; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xyj8jS+C9wqOk3KceDQTo75wMiWZgljnGSBlM8HQloY=; b=ZuuZEBvW47NvlJ5rIAv0EWm8ziXVwYcY/yPtMVJIF0JJq6pC/1B/wspQlzJPR46IPDRKO7 eleuVJHVdMhmispu97WETi2sykC75CzKSQbmUNP5Z/F5ddA4Zf4Lfudd3Mk9VqW0Dqgr+k HtR6laOj1c/RoCdBfRw9Mrn0fyguiVM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-156-1i0B0n5wO9KbojDzH-noSA-1; Wed, 16 Nov 2022 05:28:39 -0500 X-MC-Unique: 1i0B0n5wO9KbojDzH-noSA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6CE1B86F132; Wed, 16 Nov 2022 10:28:37 +0000 (UTC) Received: from t480s.fritz.box (unknown [10.39.193.216]) by smtp.corp.redhat.com (Postfix) with ESMTP id D7D7C2028E8F; Wed, 16 Nov 2022 10:28:29 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: x86@kernel.org, linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, sparclinux@vger.kernel.org, linux-um@lists.infradead.org, etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org, linux-rdma@vger.kernel.org, linux-media@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-perf-users@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kselftest@vger.kernel.org, Linus Torvalds , Andrew Morton , Jason Gunthorpe , John Hubbard , Peter Xu , Greg Kroah-Hartman , Andrea Arcangeli , Hugh Dickins , Nadav Amit , Vlastimil Babka , Matthew Wilcox , Mike Kravetz , Muchun Song , Shuah Khan , Lucas Stach , David Airlie , Oded Gabbay , Arnd Bergmann , Christoph Hellwig , Alex Williamson , David Hildenbrand , Leon Romanovsky , Leon Romanovsky Subject: [PATCH mm-unstable v1 10/20] RDMA/umem: remove FOLL_FORCE usage Date: Wed, 16 Nov 2022 11:26:49 +0100 Message-Id: <20221116102659.70287-11-david@redhat.com> In-Reply-To: <20221116102659.70287-1-david@redhat.com> References: <20221116102659.70287-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749648846897794136?= X-GMAIL-MSGID: =?utf-8?q?1749648846897794136?= GUP now supports reliable R/O long-term pinning in COW mappings, such that we break COW early. MAP_SHARED VMAs only use the shared zeropage so far in one corner case (DAXFS file with holes), which can be ignored because GUP does not support long-term pinning in fsdax (see check_vma_flags()). Consequently, FOLL_FORCE | FOLL_WRITE | FOLL_LONGTERM is no longer required for reliable R/O long-term pinning: FOLL_LONGTERM is sufficient. So stop using FOLL_FORCE, which is really only for ptrace access. Tested-by: Leon Romanovsky # Over mlx4 and mlx5. Cc: Jason Gunthorpe Cc: Leon Romanovsky Signed-off-by: David Hildenbrand Reviewed-by: Jason Gunthorpe --- drivers/infiniband/core/umem.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c index 86d479772fbc..755a9c57db6f 100644 --- a/drivers/infiniband/core/umem.c +++ b/drivers/infiniband/core/umem.c @@ -156,7 +156,7 @@ struct ib_umem *ib_umem_get(struct ib_device *device, unsigned long addr, struct mm_struct *mm; unsigned long npages; int pinned, ret; - unsigned int gup_flags = FOLL_WRITE; + unsigned int gup_flags = FOLL_LONGTERM; /* * If the combination of the addr and size requested for this memory @@ -210,8 +210,8 @@ struct ib_umem *ib_umem_get(struct ib_device *device, unsigned long addr, cur_base = addr & PAGE_MASK; - if (!umem->writable) - gup_flags |= FOLL_FORCE; + if (umem->writable) + gup_flags |= FOLL_WRITE; while (npages) { cond_resched(); @@ -219,7 +219,7 @@ struct ib_umem *ib_umem_get(struct ib_device *device, unsigned long addr, min_t(unsigned long, npages, PAGE_SIZE / sizeof(struct page *)), - gup_flags | FOLL_LONGTERM, page_list); + gup_flags, page_list); if (pinned < 0) { ret = pinned; goto umem_release;