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=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 8385BC433DF for ; Mon, 18 May 2020 19:50:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3C8A420657 for ; Mon, 18 May 2020 19:50:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aN5/Jeqm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3C8A420657 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C0DD4900003; Mon, 18 May 2020 15:50:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BBDFB900002; Mon, 18 May 2020 15:50:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AD3AD900003; Mon, 18 May 2020 15:50:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0199.hostedemail.com [216.40.44.199]) by kanga.kvack.org (Postfix) with ESMTP id 91C64900002 for ; Mon, 18 May 2020 15:50:24 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 4A9D02C8B for ; Mon, 18 May 2020 19:50:24 +0000 (UTC) X-FDA: 76830881568.19.end80_3db132cdfdd2e X-HE-Tag: end80_3db132cdfdd2e X-Filterd-Recvd-Size: 5311 Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Mon, 18 May 2020 19:50:23 +0000 (UTC) Received: by mail-pl1-f196.google.com with SMTP id k22so4657648pls.10 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=IFlCm/IyncD8KcsnmOTmDHzxoEUcVjX8pVXH77P/a4jWCQswUJeKG99KP7UrAZ8Eg8 QsDPBQfVkLGntimHFUxYWKw6QgdTR3Sd3bIJBXPhAC4//9T2cmdKij3WsWZWzlRS3xwo ee9tfkhcyF6LHSuCcMKBz+NZHyKaTVL0LZjlW01p8NRh4u/QB6cer2I9UaIO+tf9Lc0H dlKmR5M3mluHxq17XN/1ETIiQ2HTgX9qkPoXd4JJ0ncyx96d2g4TbpAUU7dmtqxewpFq 0gC22K0JWfgAcZzMKih6CyNJ+qG8ZVO2narq+l6wBaNNi0T88Ysl/erny+G4SXzIOUcS dMDA== X-Gm-Message-State: AOAM532l+vmzjE95B4jAFj7VzmDFFkGz/1wZ4OkQXpPoZQ/AVPBliP0/ QugVNAMStecg+t/2EoEwwGY= X-Google-Smtp-Source: ABdhPJzxz922YJSj9+b/H/3/FQcz0ec0Cz0IJcFFwC+zg3vg/04+H0hilaUQWV8KSV2DObhbDhLQiA== 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 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: 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