Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4111341imm; Tue, 29 May 2018 22:27:49 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLmVpPp/zk8JGmqclEyOtwpj4OOLvbenSvxeNnXF/ENV5gCRDKgC7nTFBJV90rZGqlpBnUh X-Received: by 2002:a62:1549:: with SMTP id 70-v6mr1360099pfv.91.1527658069706; Tue, 29 May 2018 22:27:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527658069; cv=none; d=google.com; s=arc-20160816; b=I9h09CJYPisM32M1S5W91+vUFaYiXhQ/NFfiQgZaxr8ds3RAKb29jo/gm+DlxqW/+6 xSxYPwMbzcUTnR1TBekFJwnhzHutCVd6Kiy9OEqOJNEp1GPaDJxrNjARMn/GtvbQzBTJ eKjCt4zukpX8x/Nd8k9YI3wgrH+LPOTOdQKXrxn8Hdha/Qx+Lcvjin5l5aLZNQJ1Nd1o gwu8LO2eHR+WMiP1NrtU/W+ct9rxvGFJ127i3mn7V9TvGUw1DS6RT0feBl+xE5BSZPef hV5wC575rMW3B89O/xmbsO+j4nyKe9xvc2GlX2ifCoOG8PmhLQq7vSACj8jjTe/TzzqA daVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=mIqPz12WOoHdzejocnUUkiva0Vma+XpmclQDDCxn3vw=; b=gLRB8FFUnhVyaKASB1fhmLikuFErr9IdtGKkqAMH0zUKQD558c8PLrn81+9NWGfNKw HGRHNCmCAD/xmTkrKGUiJLSiYGesAlZ+BZ4FsKgMx9yNfZcG8tHn7j6qyxRRfCnhU9pH UW6k/5BNMf+JzO1Epld5WAPhTyTNi17sB6ReTdQcMBTnVZp7DnkY2otzJtggNB1hLLHe FScZcEvUeyUszIdWXTZijvnWQN/fIsBREidxxOVywj9ddIt8ZqROH7bLKY8/B+THKPEf Cqs7PInDqr2qh4wrYsLjuToU6GDpSSQvY+Pwoemia0j9ZtNKfdsTGUW3qaWFnTujPm4w ObxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=l+8TklG+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id j18-v6si13256444pgv.575.2018.05.29.22.27.34; Tue, 29 May 2018 22:27:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=l+8TklG+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S933851AbeE3F1I (ORCPT + 99 others); Wed, 30 May 2018 01:27:08 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:35067 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751912AbeE3F1G (ORCPT ); Wed, 30 May 2018 01:27:06 -0400 Received: by mail-lf0-f67.google.com with SMTP id y72-v6so2251170lfd.2; Tue, 29 May 2018 22:27:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=mIqPz12WOoHdzejocnUUkiva0Vma+XpmclQDDCxn3vw=; b=l+8TklG+6EFNpuKksyJvuW80/vrUt0v3hhj4Jn/p9cv4zzL4Zb4TLFinYt1fKm/T66 2zG/XLpjFAQIU5E8gFyVrKcOE1aRPAV1UhqvPa5X8odkoOPiGZRrzmBZ3yAxlBmCFMD9 ANnxwjJQMcW7ipoWMO0cJ1PpkXSqoKInASDxOCiNes4heHPrpaXXTwyEea9EKe8K/2B5 pJFbL/yRd2GYf9+FnbZJ0qzY1FPmyZC00JJIeHDs12AH+IL4o6+tQn8IJmumC4lPfaOS 6Enmjm15nTNLC2lBGS7lycC2uGc3MOc1zl6KMyRj1EVwSb7jtjU1sr8J1tiOOJYdAbpU /H+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=mIqPz12WOoHdzejocnUUkiva0Vma+XpmclQDDCxn3vw=; b=eUvyqwPV9s2Jtl2R2jA1M9cDqTFv1AzPDgfk79jjZ74UAL1k5BOlijz2UFGTY9CqoY C69YM1KyksSO9IlC/co8QrUVvsv7zTmhYlTXavCEaUqSi9Umgjd0D9uTh96ksWFhbj30 6Q9K+n7APmd0/icjPNijA0B2HxAL6P4YkLXSpFKwAas9oqc7AE4BeOrYVn4bKdT0ur/2 I8rA5K6ukLa50hDYlLl7QKNOyzO3KsypgixJln70plA/IqeYsenQcxSL0zX+qUfkGTAG 3iDlpf+P85EQq1LuYWOihbbtXiCuYa5p7EhzcPs8d4jAhsl07/y++7bW+pLpNrJFoYzf Gz0Q== X-Gm-Message-State: ALKqPwdhkn9f2Iw6JK6iE2OQ+9Ero+uzvANT2YSvP3Mytfnxl+aQuDT6 wqJ1XCY9Ar+uPwnW7GPgwqU= X-Received: by 2002:a2e:8595:: with SMTP id b21-v6mr780419lji.131.1527658025063; Tue, 29 May 2018 22:27:05 -0700 (PDT) Received: from [10.17.182.9] (ll-55.209.223.85.sovam.net.ua. [85.223.209.55]) by smtp.gmail.com with ESMTPSA id i6-v6sm6865311lji.49.2018.05.29.22.27.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 22:27:04 -0700 (PDT) Subject: Re: [PATCH 1/8] xen/grant-table: Make set/clear page private code shared To: Juergen Gross , xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, boris.ostrovsky@oracle.com, konrad.wilk@oracle.com Cc: daniel.vetter@intel.com, dongwon.kim@intel.com, matthew.d.roper@intel.com, Oleksandr Andrushchenko References: <20180525153331.31188-1-andr2000@gmail.com> <20180525153331.31188-2-andr2000@gmail.com> From: Oleksandr Andrushchenko Message-ID: <089b3c85-cdc4-f8bd-0895-50b2b4aa4ca2@gmail.com> Date: Wed, 30 May 2018 08:27:02 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/30/2018 07:24 AM, Juergen Gross wrote: > On 25/05/18 17:33, Oleksandr Andrushchenko wrote: >> From: Oleksandr Andrushchenko >> >> Make set/clear page private code shared and accessible to >> other kernel modules which can re-use these instead of open-coding. >> >> Signed-off-by: Oleksandr Andrushchenko >> --- >> drivers/xen/grant-table.c | 54 +++++++++++++++++++++++++-------------- >> include/xen/grant_table.h | 3 +++ >> 2 files changed, 38 insertions(+), 19 deletions(-) >> >> diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c >> index 27be107d6480..d7488226e1f2 100644 >> --- a/drivers/xen/grant-table.c >> +++ b/drivers/xen/grant-table.c >> @@ -769,29 +769,18 @@ void gnttab_free_auto_xlat_frames(void) >> } >> EXPORT_SYMBOL_GPL(gnttab_free_auto_xlat_frames); >> >> -/** >> - * gnttab_alloc_pages - alloc pages suitable for grant mapping into >> - * @nr_pages: number of pages to alloc >> - * @pages: returns the pages >> - */ >> -int gnttab_alloc_pages(int nr_pages, struct page **pages) >> +int gnttab_pages_set_private(int nr_pages, struct page **pages) >> { >> int i; >> - int ret; >> - >> - ret = alloc_xenballooned_pages(nr_pages, pages); >> - if (ret < 0) >> - return ret; >> >> for (i = 0; i < nr_pages; i++) { >> #if BITS_PER_LONG < 64 >> struct xen_page_foreign *foreign; >> >> foreign = kzalloc(sizeof(*foreign), GFP_KERNEL); >> - if (!foreign) { >> - gnttab_free_pages(nr_pages, pages); >> + if (!foreign) >> return -ENOMEM; >> - } >> + >> set_page_private(pages[i], (unsigned long)foreign); >> #endif >> SetPagePrivate(pages[i]); >> @@ -799,14 +788,30 @@ int gnttab_alloc_pages(int nr_pages, struct page **pages) >> >> return 0; >> } >> -EXPORT_SYMBOL(gnttab_alloc_pages); >> +EXPORT_SYMBOL(gnttab_pages_set_private); > EXPORT_SYMBOL_GPL() Sure, I was confused by the fact that there are only 2 functions in the file which are exported as:  - EXPORT_SYMBOL(gnttab_alloc_pages);  - EXPORT_SYMBOL(gnttab_free_pages); and those were the base for the new gnttab_pages_set_private/gnttab_pages_clear_private This made me think I have to retain the same EXPORT_SYMBOL for them. Do you want me to add one more patch into this series and change gnttab_alloc_pages/gnttab_free_pages to GPL as well? >> >> /** >> - * gnttab_free_pages - free pages allocated by gnttab_alloc_pages() >> - * @nr_pages; number of pages to free >> - * @pages: the pages >> + * gnttab_alloc_pages - alloc pages suitable for grant mapping into >> + * @nr_pages: number of pages to alloc >> + * @pages: returns the pages >> */ >> -void gnttab_free_pages(int nr_pages, struct page **pages) >> +int gnttab_alloc_pages(int nr_pages, struct page **pages) >> +{ >> + int ret; >> + >> + ret = alloc_xenballooned_pages(nr_pages, pages); >> + if (ret < 0) >> + return ret; >> + >> + ret = gnttab_pages_set_private(nr_pages, pages); >> + if (ret < 0) >> + gnttab_free_pages(nr_pages, pages); >> + >> + return ret; >> +} >> +EXPORT_SYMBOL(gnttab_alloc_pages); >> + >> +void gnttab_pages_clear_private(int nr_pages, struct page **pages) >> { >> int i; >> >> @@ -818,6 +823,17 @@ void gnttab_free_pages(int nr_pages, struct page **pages) >> ClearPagePrivate(pages[i]); >> } >> } >> +} >> +EXPORT_SYMBOL(gnttab_pages_clear_private); > EXPORT_SYMBOL_GPL() Will change > > Juergen Thank you, Oleksandr