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=-5.4 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 32553C32750 for ; Fri, 2 Aug 2019 05:49:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 082232073D for ; Fri, 2 Aug 2019 05:49:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nvidia.com header.i=@nvidia.com header.b="g4+wbBM5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733202AbfHBFt5 (ORCPT ); Fri, 2 Aug 2019 01:49:57 -0400 Received: from hqemgate14.nvidia.com ([216.228.121.143]:2974 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728714AbfHBFt4 (ORCPT ); Fri, 2 Aug 2019 01:49:56 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Thu, 01 Aug 2019 22:49:55 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Thu, 01 Aug 2019 22:49:54 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Thu, 01 Aug 2019 22:49:54 -0700 Received: from [10.2.171.217] (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 2 Aug 2019 05:49:53 +0000 Subject: Re: [PATCH 20/34] xen: convert put_page() to put_user_page*() To: Juergen Gross , , Andrew Morton CC: , Dave Chinner , Christoph Hellwig , Dan Williams , Ira Weiny , , , Dave Hansen , , , , , , , , Boris Ostrovsky , , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Jan Kara , , , , , , , LKML , , , , , , , Jason Gunthorpe References: <20190802022005.5117-1-jhubbard@nvidia.com> <20190802022005.5117-21-jhubbard@nvidia.com> <4471e9dc-a315-42c1-0c3c-55ba4eeeb106@suse.com> X-Nvconfidentiality: public From: John Hubbard Message-ID: Date: Thu, 1 Aug 2019 22:48:15 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <4471e9dc-a315-42c1-0c3c-55ba4eeeb106@suse.com> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL104.nvidia.com (172.18.146.11) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1564724995; bh=OWvjPY2RJnSXiNaT1G8Eyahp8MUAsm98cTkExQmaDUY=; h=X-PGP-Universal:Subject:To:CC:References:X-Nvconfidentiality:From: Message-ID:Date:User-Agent:MIME-Version:In-Reply-To: X-Originating-IP:X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=g4+wbBM5eRNl11+v4FSAl8PrvEnWACjbjTJMUv4Ewv3g+h7PgD8hueH5dPeoF8sW5 c20eFrVi38BUjWugKSUxA2GH7CM3A3OrXQMppFfNCHg/NTgln/g1EuAeIEfsheR70J 47ajhTYRdBziMz0qVCHRjvKDjLN869T+rpjyKMqZQbhfLl80UOF5a6wxQMkyYeuu5C +SnQBQbOJUSigTfdZ2ZjmuC0GsGJhOMqTD72slI2rg2m1d7LKmLad2tBrS2UUN+9aI ixGXEdOyIH0YMQhEWsNGgp8xCyCNq0cOZ0EzzfGMekaZZJReXbXnLe2japHjsnQzSN gxuwPmkfTC8TQ== Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org On 8/1/19 9:36 PM, Juergen Gross wrote: > On 02.08.19 04:19, john.hubbard@gmail.com wrote: >> From: John Hubbard ... >> diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c >> index 2f5ce7230a43..29e461dbee2d 100644 >> --- a/drivers/xen/privcmd.c >> +++ b/drivers/xen/privcmd.c >> @@ -611,15 +611,10 @@ static int lock_pages( >> =C2=A0 static void unlock_pages(struct page *pages[], unsigned int nr_pa= ges) >> =C2=A0 { >> -=C2=A0=C2=A0=C2=A0 unsigned int i; >> - >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!pages) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return; >> -=C2=A0=C2=A0=C2=A0 for (i =3D 0; i < nr_pages; i++) { >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (pages[i]) >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 put_= page(pages[i]); >> -=C2=A0=C2=A0=C2=A0 } >> +=C2=A0=C2=A0=C2=A0 put_user_pages(pages, nr_pages); >=20 > You are not handling the case where pages[i] is NULL here. Or am I > missing a pending patch to put_user_pages() here? >=20 Hi Juergen, You are correct--this no longer handles the cases where pages[i] is NULL. It's intentional, though possibly wrong. :) I see that I should have added my standard blurb to this commit description. I missed this one, but some of the other patches have it. It makes the following, possibly incorrect claim: "This changes the release code slightly, because each page slot in the page_list[] array is no longer checked for NULL. However, that check was wrong anyway, because the get_user_pages() pattern of usage here never allowed for NULL entries within a range of pinned pages." The way I've seen these page arrays used with get_user_pages(), things are either done single page, or with a contiguous range. So unless I'm missing a case where someone is either a) releasing individual pages within a range (and thus likely messing up their count of pages they have), or b) allocating two gup ranges within the same pages[] array, with a gap between the allocations, ...then it should be correct. If so, then I'll add the above blurb to this patch's commit description. If that's not the case (both here, and in 3 or 4 other patches in this series, then as you said, I should add NULL checks to put_user_pages() and put_user_pages_dirty_lock(). thanks, --=20 John Hubbard NVIDIA