Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp492260imm; Fri, 1 Jun 2018 04:47:19 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKL1UoyEW/HpjrMe+DGpD0GdFbaGaJbmyfQhSMMoLu8l6p8bZ5xSSBe95Gw9zrRhV7IKnbe X-Received: by 2002:a63:755d:: with SMTP id f29-v6mr8573509pgn.278.1527853639621; Fri, 01 Jun 2018 04:47:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527853639; cv=none; d=google.com; s=arc-20160816; b=KUR0tlEloZibaXKVcE6V2z3cQV2MuBmFGi3AnlyfRONdtgksPGf9Snq2ChzZi4K4nJ /OfOZbw+Qtz3L5Fe7k38plSQdNaNTzYJO5g8fbYBrJTnzxnpPDbxIS6zkeuMcMxehnIQ 8mdHZU+yMsyCNJbfrEUww5sT43QmR6Q19TcWJaiidrWLIHwY09McHzyTHZybX17EHAEi 4XkNvbv+2gcEYzVhEwJbPDDibPiIF7VT3MzQ8s65tPgx8o6LhIa0izzFTEhljjjzzRjl heFjNY/6daQ6eqxwzEup+ZNUQ77vixQr5APszEJG+gcUMAptRprqpeN3Vyzty6sTOLfH JlIw== 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=TK8kkmLB+HMb8vp6WxHa7AnIL/bAGMzUO0BSsi7U/Yk=; b=K3lQscBcBLuwDwwImAN0PI/EN5nv1zdBybq9aINNKj/O9MLzsHIFF2oiMkXiQkUX3Q zBazVwiTcrnMvMLAnJlKXNIJf//5ZneUpBnZEINO3xOS0UqhqO16B28jNTAWxg9UZl5C pqOHpFMgkgzdGTvHFMLZ5gPzX8yoOyu0J52E5yJgwl80U74SBqYY1nUADev59G722VOI ZOJDnbpjj3x8FYNTfBYpyW6FlUfjaxyhmEl4cObEBm1Bx7khxLCe8zpr+CAJe6E6p6Me RMYPwJktbLm8vUkl9WhLS6hgDgIpSWYKtUDQaNS4Gdgq5LEk6K7oD7dsRm1dFJXHTZIS 7l/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fSgNwBm0; 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 u13-v6si31054282pgr.593.2018.06.01.04.47.04; Fri, 01 Jun 2018 04:47:19 -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=fSgNwBm0; 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 S1752257AbeFALoq (ORCPT + 99 others); Fri, 1 Jun 2018 07:44:46 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:38376 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752022AbeFALom (ORCPT ); Fri, 1 Jun 2018 07:44:42 -0400 Received: by mail-lf0-f66.google.com with SMTP id i83-v6so2225608lfh.5; Fri, 01 Jun 2018 04:44:41 -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=TK8kkmLB+HMb8vp6WxHa7AnIL/bAGMzUO0BSsi7U/Yk=; b=fSgNwBm0Uph7t+NUaW1p0hFJmBCzGARmM3Rro4s0XenkWK69peimLeGIBmEAR+M61O 1RDxvEAQk+D9SAjJZydAorv1/yk5SWgu2WIrJGx82hVHXrHg4k/yCAQYEnmiLShm5hZs bWCLKdN7gic43sFtqEzpMWgO7aHwesIwqg3Li7o8ZvKy0jPVY7pRB7dfSdeWMVxVcYWN yAtFZS5Is9OVim1zmYJsLHnW6t3tCh9ILMZorCBDcCGc1QzaA0Gum+fhwygNE1GdzNet pKspiY8dKNhjCy0fSGttvRZFyde/2NSxNm9YZQsREy3a1k+3L2De97gnvazc07cNDUaX pX0Q== 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=TK8kkmLB+HMb8vp6WxHa7AnIL/bAGMzUO0BSsi7U/Yk=; b=c3Q1uRbOQNW44ZwjcVGK0L8Db0Mu5IL9r9WH+mZ5hYU18kPZhLtPk53hjuybPl4NIX vLweTlerJWUmrsdQYypsK2XlVQ8l5ohvgd5GxATous5fnDW6OjjZdItUQig3Ob9vfZpx iuPql6QpiXCww9mTmv/FaFb7ywQmo7u5+46gxcHR8eofu7mPUYz0523AnUGLymcM7UpV Rl/VKvlUxKEmfDyuJc/9ILblTmQi2RaCqHWcVq/LLdiBjBvDxXdI+dYpX/MTpApTEFKq jsCk7EH5s231VVy0vcF87MnyqqGA0mxhEcHkAdxdczFE92julrrP6xq3BahhkN/Isndi WMPg== X-Gm-Message-State: ALKqPweKoWrem3iJeAx22xeHo/90XIOp19jiWAESgJCWzn4rS+JMq+Cf gIOPx59BhNtnK5LBvZXIrpc= X-Received: by 2002:a2e:4792:: with SMTP id u140-v6mr8222702lja.2.1527853480339; Fri, 01 Jun 2018 04:44:40 -0700 (PDT) Received: from [10.17.182.9] (ll-51.209.223.85.sovam.net.ua. [85.223.209.51]) by smtp.gmail.com with ESMTPSA id u85-v6sm218244lfi.5.2018.06.01.04.44.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Jun 2018 04:44:39 -0700 (PDT) Subject: Re: [PATCH v2 2/9] xen/grant-table: Make set/clear page private code shared To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org, jgross@suse.com, 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: <20180601114132.22596-1-andr2000@gmail.com> <20180601114132.22596-3-andr2000@gmail.com> From: Oleksandr Andrushchenko Message-ID: Date: Fri, 1 Jun 2018 14:44:38 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180601114132.22596-3-andr2000@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Boris, I dropped your r-b for this patch as I changed EXPORT_SYMBOL to EXPORT_SYMBOL_GPL as Juergen requested On 06/01/2018 02:41 PM, 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 ba36ff3e4903..dbb48a89e987 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_GPL(gnttab_alloc_pages); > +EXPORT_SYMBOL_GPL(gnttab_pages_set_private); > > /** > - * 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_GPL(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_GPL(gnttab_pages_clear_private); > + > +/** > + * gnttab_free_pages - free pages allocated by gnttab_alloc_pages() > + * @nr_pages; number of pages to free > + * @pages: the pages > + */ > +void gnttab_free_pages(int nr_pages, struct page **pages) > +{ > + gnttab_pages_clear_private(nr_pages, pages); > free_xenballooned_pages(nr_pages, pages); > } > EXPORT_SYMBOL_GPL(gnttab_free_pages); > diff --git a/include/xen/grant_table.h b/include/xen/grant_table.h > index 2e37741f6b8d..de03f2542bb7 100644 > --- a/include/xen/grant_table.h > +++ b/include/xen/grant_table.h > @@ -198,6 +198,9 @@ void gnttab_free_auto_xlat_frames(void); > int gnttab_alloc_pages(int nr_pages, struct page **pages); > void gnttab_free_pages(int nr_pages, struct page **pages); > > +int gnttab_pages_set_private(int nr_pages, struct page **pages); > +void gnttab_pages_clear_private(int nr_pages, struct page **pages); > + > int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops, > struct gnttab_map_grant_ref *kmap_ops, > struct page **pages, unsigned int count);