Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp3025947ybk; Mon, 18 May 2020 14:00:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5iDQK8YvEdQJQUXJl+X193IrWYOgVZ/g4S8+e79b3Btjllm2SC2Yeh9ooNkg3UIibWp6m X-Received: by 2002:a50:9b19:: with SMTP id o25mr16294448edi.141.1589835648065; Mon, 18 May 2020 14:00:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589835648; cv=none; d=google.com; s=arc-20160816; b=RvB4O770hYLF8UtTJcqPNjgB+21IleKX4AygEI7o6AdI7ZInFXXbYxnUJJ98MUrgGF N8COy1nTiP86GM1t/PZN+BhxhgjgR7VLCsb+YUisXcosevkJJErwL49g4pR02IshReKW qNeVg5lwZ0Fl2INweO+RcC06LW3OX2ql8/ouyKbuFFpDeFBMmU7VjdAfPXi3ip9PN2DF jOiHOvxOZvhy3O9Exday1gfaRDbHu22KlfOSChmdBIsYL2u4t6kIY3OdxVq/Ro9NFuLG A4muzfGllN4zg8th4BIjO799fipS6/t4Q3Rtm2AHUOtEGLadenpR+ikg9bCK6SA5X1tN 5n5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=hRgohj4ZV7BAqug+Up6EM0XNiUu7ZgBs3u6nUNC3XVM=; b=TgQEmOIHSSgk5cqduVL2tco2IwQ7hUTGaCPBUeLSo6Szu0vNykgA4Fi6uxCaj76RPM D/ePUxizo7kcHh07YymcCEoMRUBx73JQwBVMyenY7RX7mmYpJ9Bzv+AtpJFJNV+e4+Bj kQjRU/5f/FWv/wHGtWUVrAsljbChKl1xJLaoFEG1ohBP0atlpJODGYT7ECKGaWGBjtau SdJ5iTlGm3cZ7K1siuIiwTEElytALzH2iAyhLIMbv5qc8Jm+4nBXlJDXDJF7KuOck7/c W1P9NU02c84NQcSOyT8ZsZcKETJbDcGRGaOZ7EYTVPR09LbQ0Kg0CFr2tmhx4iNIWNR/ 9Q4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="rOdNevU/"; 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 w20si1895671ejf.208.2020.05.18.14.00.24; Mon, 18 May 2020 14:00:48 -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="rOdNevU/"; 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 S1727999AbgERU6r (ORCPT + 99 others); Mon, 18 May 2020 16:58:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726270AbgERU6r (ORCPT ); Mon, 18 May 2020 16:58:47 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88B26C061A0C for ; Mon, 18 May 2020 13:58:45 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id k5so4799069lji.11 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=n+dRvPeO/+Xds5M9M3wEDXekmf/Eh2PkQl8sTjl8rhXrOZXnXsu1RUWRA7fHmD5C66 viGgMQ/mGrgtP56ctA9SKuUqnjx2GXfn9OrIWN0xX1Wfp7YBPD1t8uB/xKIjlXYc7kWi BKkLCVdlcTCLiF7vQxJ2a/VWk6lsx4I89I9cXGc1CRkiPJIOMx47Yz7/az4DEUB6IGjw jbC4EYW9+6N8G4lyGW2L0slnyVLM5+ZWyPCWx3YGyY5HKLIbYQiwYn5uSnWtvfQ4i/Pa jc0kYA1QcIRGRxbKm695hIlUrOtL8wdve+o31z6XX26+I9M9l0hhMs6/j1oUOY7Hf6WI g80A== X-Gm-Message-State: AOAM531aH3RCYtYSy2Wd7D+tmMy7KVJKMkF46O37T0nof5SgbZWfAKH2 ul3i91Cz/gJSynjZPXJlUmGNKrF0kDfgi8L+rHp7L4je 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" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; > > >