Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3250642pxk; Mon, 28 Sep 2020 12:15:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJye6rxBb/fT9L5kbg9HWgWIQGnt7Y0XgjPcrngNlORUtLap5OSBrEb+knlzS1pVapJbUxo0 X-Received: by 2002:a17:907:70cb:: with SMTP id yk11mr286845ejb.312.1601320525732; Mon, 28 Sep 2020 12:15:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601320525; cv=none; d=google.com; s=arc-20160816; b=Q1O/Y8e4l+N5BXxn8joTp9K3Ow34gRPqwLCfPvGtnX467Qbm0Ic+dwbou0JTZDAt/u yRL2VI6S47qHvjZQvpGz9W+J379ywvH4+5NsQ+SZ6eLkchW55KeNx7eePvGOFYV9PvQq ekUT5T4hVsBZtUdwBHGb2x9uVPbMxNCf6guq5XolCoVSMiJ4hSGsJ+deqbYwrJbDMaM4 RcAFd+qMfSrt/D/gMJ2p3DdFrU/lwl/lKoBhwqEemOAYa+0S/8ZJynmBXhsWahZX0ZCd cpBrkFunBRcMmmxB3fat9tbByI8/eqw+hkjacmG8+ZtxvrxHy0vryQcM9tuMckChiMmZ Hdcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:dkim-signature; bh=wL+FSbzPDyTOZYHdyTb21RdbTIUYUYpk4JKjFqxA86c=; b=qQdKuWu/Jk9TrPXGdBeuHQTIN00Wy812eJc6z1ZAKKPyb2RZQ3tzqm5hBUiy/ldzR8 2WOFzzxIV+da4BktBGKKJp7RSpAh8iynDM9bDabPemuYujVMc0tSpuA5JlcZMSPXSLM/ T6np6uBBTc4U4Sq79p74xG3AItZeGk8kyeQTEQgSk4HdgFMN+3lQi4taTl3C30xKNTgV vnFzSfy3Dn54odAFOAGGH//dC2DlbFE2YvguSlRZIolY9M/5fvsj18f+XCx4EEbKnXpY Fs4ftGD/TA9bzU3wlEU0Wikjgvf5wPvPz/skEbWL/JGrqN4PSD874XryONb6SdFwvlom MSlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=jnhx7F4Q; 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=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i6si1276628ejs.301.2020.09.28.12.15.02; Mon, 28 Sep 2020 12:15:25 -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=@oracle.com header.s=corp-2020-01-29 header.b=jnhx7F4Q; 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=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726734AbgI1TNP (ORCPT + 99 others); Mon, 28 Sep 2020 15:13:15 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:38614 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726696AbgI1TNO (ORCPT ); Mon, 28 Sep 2020 15:13:14 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 08SJ90B3005177; Mon, 28 Sep 2020 19:12:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=wL+FSbzPDyTOZYHdyTb21RdbTIUYUYpk4JKjFqxA86c=; b=jnhx7F4QDGM1NbmcFShUQeKxzQtv/FzNCBRIsBkwEQLErIqyQUey6TgIGFgKX7uHgxiW F9ni7U2s7HEgZXKtynTlY11+yJOzYADgZMp68Zihx4UrjNBV+2yr5UVpOQQPi7JEoSVv 8FdlqPxaraU8lm2MrDyrL8VXC9W9L/bnM0kgFxIxTlvcIMfhLygVSErP/gGWHXBsLIY2 2Hhok61N4fxmajmXTKNsRx6QuD+4ZGMQyO9HYLggNt+u6KG6uE/7XbDJRy3msKXdCMVH LV8sRdBZ7/vP7dW8wzdiKpkwHsgZN/Lt2pMcJyaJQSgiv5MP89H0idklvHh5b/IBP0fP SQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 33sx9mxt5x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 28 Sep 2020 19:12:46 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 08SJAOOe011172; Mon, 28 Sep 2020 19:12:46 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 33tfhwnf26-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 28 Sep 2020 19:12:46 +0000 Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 08SJCbl6008284; Mon, 28 Sep 2020 19:12:37 GMT Received: from [10.74.86.78] (/10.74.86.78) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 28 Sep 2020 12:12:36 -0700 Subject: Re: [PATCH v5 10/17] mm/memremap_pages: convert to 'struct range' To: Dan Williams , akpm@linux-foundation.org Cc: Paul Mackerras , Michael Ellerman , Benjamin Herrenschmidt , Vishal Verma , Vivek Goyal , Dave Jiang , Ben Skeggs , David Airlie , Daniel Vetter , Ira Weiny , Bjorn Helgaas , Juergen Gross , Stefano Stabellini , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , dave.hansen@linux.intel.com, linux-mm@kvack.org, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org References: <160106109960.30709.7379926726669669398.stgit@dwillia2-desk3.amr.corp.intel.com> <160106115761.30709.13539840236873663620.stgit@dwillia2-desk3.amr.corp.intel.com> From: boris.ostrovsky@oracle.com Organization: Oracle Corporation Message-ID: <6186fa28-d123-12db-6171-a75cb6e615a5@oracle.com> Date: Mon, 28 Sep 2020 15:12:32 -0400 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.2.2 MIME-Version: 1.0 In-Reply-To: <160106115761.30709.13539840236873663620.stgit@dwillia2-desk3.amr.corp.intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9758 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 malwarescore=0 adultscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009280146 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9758 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 suspectscore=0 phishscore=0 mlxscore=0 lowpriorityscore=0 adultscore=0 clxscore=1011 spamscore=0 impostorscore=0 malwarescore=0 bulkscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009280146 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/25/20 3:12 PM, Dan Williams wrote: > > diff --git a/drivers/xen/unpopulated-alloc.c b/drivers/xen/unpopulated-alloc.c > index 3b98dc921426..091b8669eca3 100644 > --- a/drivers/xen/unpopulated-alloc.c > +++ b/drivers/xen/unpopulated-alloc.c > @@ -18,27 +18,37 @@ static unsigned int list_count; > static int fill_list(unsigned int nr_pages) > { > struct dev_pagemap *pgmap; > + struct resource *res; > void *vaddr; > unsigned int i, alloc_pages = round_up(nr_pages, PAGES_PER_SECTION); > - int ret; > + int ret = -ENOMEM; > + > + res = kzalloc(sizeof(*res), GFP_KERNEL); > + if (!res) > + return -ENOMEM; > > pgmap = kzalloc(sizeof(*pgmap), GFP_KERNEL); > if (!pgmap) > - return -ENOMEM; > + goto err_pgmap; > > pgmap->type = MEMORY_DEVICE_GENERIC; Can you move these last 5 lines ... > - pgmap->res.name = "Xen scratch"; > - pgmap->res.flags = IORESOURCE_MEM | IORESOURCE_BUSY; > + res->name = "Xen scratch"; > + res->flags = IORESOURCE_MEM | IORESOURCE_BUSY; > > - ret = allocate_resource(&iomem_resource, &pgmap->res, > + ret = allocate_resource(&iomem_resource, res, > alloc_pages * PAGE_SIZE, 0, -1, > PAGES_PER_SECTION * PAGE_SIZE, NULL, NULL); > if (ret < 0) { > pr_err("Cannot allocate new IOMEM resource\n"); > - kfree(pgmap); > - return ret; > + goto err_resource; > } > ... here, so that we deal with pgmap in the same place? The diff will be slightly larger but the code will read better I think. -boris > + pgmap->range = (struct range) { > + .start = res->start, > + .end = res->end, > + }; > + pgmap->owner = res; > + > #ifdef CONFIG_XEN_HAVE_PVMMU > /* > * memremap will build page tables for the new memory so