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=-0.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 13744C433E0 for ; Mon, 18 May 2020 20:58:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BD5D220758 for ; Mon, 18 May 2020 20:58:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rOdNevU/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BD5D220758 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 5B24780005; Mon, 18 May 2020 16:58:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 58AEB900002; Mon, 18 May 2020 16:58:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4C70080005; Mon, 18 May 2020 16:58:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0085.hostedemail.com [216.40.44.85]) by kanga.kvack.org (Postfix) with ESMTP id 36284900002 for ; Mon, 18 May 2020 16:58:46 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id D7D3D180AD81A for ; Mon, 18 May 2020 20:58:45 +0000 (UTC) X-FDA: 76831053810.26.cow93_4c7c735452e2b X-HE-Tag: cow93_4c7c735452e2b X-Filterd-Recvd-Size: 5870 Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Mon, 18 May 2020 20:58:45 +0000 (UTC) Received: by mail-lj1-f194.google.com with SMTP id l19so11391631lje.10 for ; Mon, 18 May 2020 13:58:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hRgohj4ZV7BAqug+Up6EM0XNiUu7ZgBs3u6nUNC3XVM=; b=rOdNevU/0mLEdSxCbmh65V2KFMBeoX//d0FtXPHjZ8d9daBS8aYWdyHgpcqgGnTI34 QACNCLwNTer3Xdk2mYreZ/8bieP7gG4rNZsMHonf/mfI/NXQg8eXQdBK93azmIjHz5kR HKFluM3XIKkNA96y/QJyispsiw7mGOYH2kvpzm3OATveSrYAtGpzXCIJ8JVq2OTYmxNS X1KAVninjF+PklHw217wXvsCV0/Ugi4UKa7UBDBQ+p6OMcMGnsnhAO1DqDZQHBsBsp8d 00D5NwNEEJQXEAMJhPvzhUj10L+QzKTHDVYavpLzWy/8eelKEBtAV8UWleNILT29Gr9/ pjOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hRgohj4ZV7BAqug+Up6EM0XNiUu7ZgBs3u6nUNC3XVM=; b=IIaeJ5crcV2SEZFLXhShF5kOP4eK89EptDU57DAS14Jqs3t++MGL0JpgUWRONXmBkA 1i8bKfs2pjy1xpfWwX0LqMDKPt3mJ4MGdtHONTKqZuLMypBxhtUIhs/Iwxz/QfNF8nSH n7ekY8OxRx5y0vGk1krtjZDCsbEF03Pwv7RA7KWZT178ecSVTAGPbW3I2fS/MS/iCqGV kY5y18ndc+Z7ET8dkojznzvW5avZKpEeFef14DXji+37gYoMhLASj88sB50HETwIWhV3 9zMZIl1bD5VPH3FvWjm2EFPYgrby6kBy1rQ//bnRz45bjImHM29PubBxseuDF2oTMy0B anfw== X-Gm-Message-State: AOAM531ban6ZL5kBi6+7rqMqeK5UTsU4bCY6YbgRiHYhmssY1teCzY2D nuIR3E2gDGfblSe/Jz/8pSYkBg3LmekX/WtTvHs= X-Google-Smtp-Source: ABdhPJz0uicoFSCahdZXLSYMWd5wQ4xkgjldsqXDe1+/Xhg5qmkvdblvgGEByl8zYDmZjNVc8BMpJF8C7muKhSE+qpA= X-Received: by 2002:a05:651c:1a5:: with SMTP id c5mr11319490ljn.217.1589835523866; Mon, 18 May 2020 13:58:43 -0700 (PDT) MIME-Version: 1.0 References: <1589831903-27800-1-git-send-email-jrdr.linux@gmail.com> <20200518201737.GV16070@bombadil.infradead.org> <975cc333-e9f4-29e4-db0e-00ea8b8a7c25@nvidia.com> In-Reply-To: <975cc333-e9f4-29e4-db0e-00ea8b8a7c25@nvidia.com> From: Souptick Joarder Date: Tue, 19 May 2020 02:36:45 +0530 Message-ID: Subject: Re: [RFC] mm/gup.c: Use gup_flags as parameter instead of passing write flag To: John Hubbard Cc: Matthew Wilcox , Andrew Morton , Linux-MM , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" 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: On Tue, May 19, 2020 at 2:15 AM John Hubbard wrote: > > On 2020-05-18 13:44, Souptick Joarder wrote: > > On Tue 19 May, 2020, 1:47 AM Matthew Wilcox, wrote: > >> > >> On Tue, May 19, 2020 at 01:28:23AM +0530, Souptick Joarder wrote: > >>> 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. > >> > >> Uhh ... until you change all the callers, haven't you just broken all > >> the callers? > > > > All the callers have called the API with either 1 or 0. I think, it's > > not going to break > > any of the callers. > > Maybe so, but it's still "wrong" to do that, because it only works more > or less accidentally. That is, it works in spite of a type safety > violation. So we don't want to do that sort of thing unless there is > a compelling reason. > > In addition to that, I am at the exact moment putting together a minor > refactoring of this function, because I need a FOLL_PIN variant: > __pin_user_pages_fast(), as part of my work to change over a few dozen > gup call sites to pin_user_pages*(). > > (In fact, I was wondering whether to stick with the "write" parameter, for > the new __pin_user_pages_fast(), or go with gup_flags. That could go either > way: gup_flags provides a nicer API, but "write" matches the existing > callers.) > > So in other words, if you do go out and change all the call sites (there only > seem to be about 7, outside of gup.c, actually), that's going to conflict > a little bit with what I'm doing here. > > So, how would you like proceed? If you want to do the full conversion > (which really should include the call sites), it would be easier for me > if you based it on my upcoming small patchset, which I expect to post > shortly (later today). Sure, I will wait for your patchset :) As there are only 7 callers of the __get_user_pages_fast(), I prefer to do full conversion in a single commit. But if it is not preferred way, I would go as per feedback. > >> > >>> -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; > > >