Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2994349ybk; Mon, 18 May 2020 13:05:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzisux33d1LDgs7EFsg07JQ69elumRS9UHT3zLHrp4P8YW88rvaPekVowo8hR71O5znMWXj X-Received: by 2002:a50:c60c:: with SMTP id k12mr14672705edg.111.1589832312530; Mon, 18 May 2020 13:05:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589832312; cv=none; d=google.com; s=arc-20160816; b=0wrdAWFR+JYkKsbx9kNVhX0Asm+oCxWkKOEnm5G5YQsPUzVxtLf/whDwOUs6EGQ+xO AqXX+tmdDZYR1HxDwzqUgcVP30EUbF05bg1aCFn1eo4EofWkhjh32Xc+PBOd1GHWNh8A aRJUXF3CvOQiAqlNb286DbsQuD4FNMfz8UZrQ8WnlfS4aBFlxm1Fd81Yg4FySg+9YiS5 fpHoa4HIk2Bv7l/VvTv0WkupnoN6PKHA2c2/eopdzrHzNACF4xGQWO/q/B8CkTWyAL7B xqXnn1gNQoaMVg+Plpnf6MwYqubKIDPSw2z7zQHg7fJHQudTnMhJY7a8l7A9/fadHZJ1 UKlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=RTFGezog0FoY0Led7GpUdftvReGrQNJe75seXSSvjsQ=; b=XlPDAwmX3YDPi/qTzMEA8nUdvOQAiLMglmJ5UHNee/Xd/3aHuqdSdZ77ZYV/5sZFf/ mzpZpuJgNg+3v7Ms6A2/2w7t3nlE9muP8wT7LN9OAePBpd0he3ZtB03+s13FeBBAxoWp I1UnnkKBBzLliExdrpPzbH+WITHXsq2NFbIZuBkbUhehnnAOeoPRR+MgCGYbQmqH03Yw kN2eXbDXCjNsrjaJJokhOmqZ1hMjxQEPzff3EsvjSLJ1T8yBnKgKDckq2ZmLnFqrUI+8 ZPDhYRXdJvDA5lJa+/UT8PVbOQ2o3CBCoaaMT77KDkm0v7mZfES2auVaeXaUQfcdPUbK LFiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="aN5/Jeqm"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i9si7189043edb.594.2020.05.18.13.04.49; Mon, 18 May 2020 13:05:12 -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=@gmail.com header.s=20161025 header.b="aN5/Jeqm"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728491AbgERTuY (ORCPT + 99 others); Mon, 18 May 2020 15:50:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727817AbgERTuX (ORCPT ); Mon, 18 May 2020 15:50:23 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 869CFC061A0C for ; Mon, 18 May 2020 12:50:23 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id t16so4665412plo.7 for ; Mon, 18 May 2020 12:50:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=RTFGezog0FoY0Led7GpUdftvReGrQNJe75seXSSvjsQ=; b=aN5/JeqmGf5VFuqGc7Bp3OhmbnvAmgN7kOlSVI7s9M0c3M03M+ciSidQfTvhY6JtYY UHkjtoF8hLmordukc8/WQfagYmjsy8KOKGqYW4Cm8GFGNjwXOjvJEsjcSoENzJEK+DzU Qp1GagSZSVz5wU83TyyrFIriBTkcq6Ue4xIIAmwBEgq28r5IrJtqhz8Z7CBOPbVpAsoC e8HkIIlXMsn+TW0eailqAcelTtx5Z5Sh3hhV9uGSTUc+EgEir2EQTKBQTxn+FZi0jxdz rUwC/347ujt/bRRFpN5dsIfIMzo4NdKEWnYJSS5rrQH/Q2EN0++ajkn1+Hhej9tpOtSR bx8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=RTFGezog0FoY0Led7GpUdftvReGrQNJe75seXSSvjsQ=; b=rocwatnpmVUZSoHR1X1xXvPDETg0zGnD9GCokVLEtx/GFrGk126sjkRcuYhpDq76+y 3frTy2xCgh0o6+nCe3rcI8bKywXx4GI2/1/VRznDFd15FIhgswtwqqmxVci0iTycsX3e Y1s0H8J2g2bw3SoSzgZ4Yzoj+QlPGG6TAItNiyHLK9o/Josqc60pJoo+H3DXUtMPDIjD 0l1TvbRmM3rGAmBAYFhYeNvMKWW/sn5h1bTwcFr3gt63EvinmpiELWlyjyRb5+ivcKk5 ZvSOFS8avvMBAgZH2dg9KMXDo32BE7qkINBcVC/OZi4AE1m+KvLxlT3xWehn4fUO7cRx p75A== X-Gm-Message-State: AOAM530Bkajtuie2kxCFItgFGLIpHq0c2Bu/wEbLotIzYdmhmDHTkAj7 ZiLmFoE6C5s+rn/ic8YV0NA= X-Received: by 2002:a17:902:bf43:: with SMTP id u3mr2436681pls.240.1589831422763; Mon, 18 May 2020 12:50:22 -0700 (PDT) Received: from jordon-HP-15-Notebook-PC.domain.name ([122.171.164.1]) by smtp.gmail.com with ESMTPSA id n21sm300181pjo.25.2020.05.18.12.50.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 May 2020 12:50:21 -0700 (PDT) From: Souptick Joarder To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Souptick Joarder Subject: [RFC] mm/gup.c: Use gup_flags as parameter instead of passing write flag Date: Tue, 19 May 2020 01:28:23 +0530 Message-Id: <1589831903-27800-1-git-send-email-jrdr.linux@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The idea is to get rid of write parameter. Instead caller will pass FOLL_WRITE to __get_user_pages_fast(). This will not change any functionality of the API. Once it is upstream all the callers will be changed to pass FOLL_WRITE. Updated the documentation of the API. Signed-off-by: Souptick Joarder --- include/linux/mm.h | 4 ++-- mm/gup.c | 18 +++++++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 5a32342..15dd594 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1816,8 +1816,8 @@ extern int mprotect_fixup(struct vm_area_struct *vma, /* * doesn't attempt to fault and will return short. */ -int __get_user_pages_fast(unsigned long start, int nr_pages, int write, - struct page **pages); +int __get_user_pages_fast(unsigned long start, int nr_pages, + unsigned int gup_flags, struct page **pages); /* * per-process(per-mm_struct) statistics. */ diff --git a/mm/gup.c b/mm/gup.c index 87a6a59..a8f869e 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2666,7 +2666,14 @@ static bool gup_fast_permitted(unsigned long start, unsigned long end) } #endif -/* +/** + * __get_user_pages_fast() - pin user pages in memory + * @start: starting user address + * @nr_pages: number of pages from start to pin + * @gup_flags: flags modifying pin behaviour + * @pages: array that receives pointers to the pages pinned. + * Should be at least nr_pages long. + * * Like get_user_pages_fast() except it's IRQ-safe in that it won't fall back to * the regular GUP. * Note a difference with get_user_pages_fast: this always returns the @@ -2675,8 +2682,8 @@ static bool gup_fast_permitted(unsigned long start, unsigned long end) * If the architecture does not support this function, simply return with no * pages pinned. */ -int __get_user_pages_fast(unsigned long start, int nr_pages, int write, - struct page **pages) +int __get_user_pages_fast(unsigned long start, int nr_pages, + unsigned int gup_flags, struct page **pages) { unsigned long len, end; unsigned long flags; @@ -2685,10 +2692,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write, * Internally (within mm/gup.c), gup fast variants must set FOLL_GET, * because gup fast is always a "pin with a +1 page refcount" request. */ - unsigned int gup_flags = FOLL_GET; - - if (write) - gup_flags |= FOLL_WRITE; + gup_flags |= FOLL_GET; start = untagged_addr(start) & PAGE_MASK; len = (unsigned long) nr_pages << PAGE_SHIFT; -- 1.9.1