Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5255709imm; Wed, 12 Sep 2018 03:29:45 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYyHpZtN0lx4N8jjqAXNA4akjrXMQrsD7rtEOyLx7IKbEr8vo1icmlpYOyemOmLzNPld/Z9 X-Received: by 2002:a63:6fca:: with SMTP id k193-v6mr1412526pgc.360.1536748185908; Wed, 12 Sep 2018 03:29:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536748185; cv=none; d=google.com; s=arc-20160816; b=feMH4T9u/ANZHrxI+HmdD4wCu45LeGELO5UlcGcBLmlKUjzt4PdUCi7EjoDn7z5cYF 19U+iFyAPmKl04Y4FrRSnpI8Aj25pkAd/XW3l3vvf0WFMBCNfUtLcQYK7EAvWiD/aPJf Ys/oC5qv13v2A1oYCkqXBnFnpNhDhgxaFfwk8boKupDD8E2nJway77HDWPTV/fl9nEqP FCWN2HRxoCJHvIGrYS02xu7mnwwNSOSmlxNsqymgbFPHwytNDf2qIMy8ROPMzZym3gxj EQsoy4gAKfp18sWOdohmVvGp8MEH2b+K2A0CdvLqO/sLZxus8CauGp1Uv5aMY/yHHsoE Y3DA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=W/oBIE0NGLLepnAxYaxQyhbv7P6nbpFfaDfp1Tx0WhQ=; b=BZwR6Ab6Y9rQZ2Tev+oEisjCWfUAmRORXm4wrKvPJzPs9rKL0eeZRyGJwLQ7ikr52N xG1fRG55Z/uuav2QmHQDapE8hjPGD8fjqh2CSfVkoJcPPh8qM6HAdUoeDcwKI9fRJYuS tN+WpPNIAkQG3mtGgjM878GPEZvEpqH65EWlhXjbXA/wIe4Cfg5pH4xz/Mu5ZKjdVv03 gz9nudr9JgtNtfiwYeub2NH2FAqYB90JTkmTiBvR+LJA8Ko4x23wLe/aB/u9BAlV/Cb6 /BB7t37z5aate9UEMGgQ7/A1w9WKvbhjRUh2JQzIigLCsLTpq+7levUauBkGRXiHD04v vJaQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h9-v6si707185pgk.121.2018.09.12.03.29.30; Wed, 12 Sep 2018 03:29:45 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727441AbeILPdO (ORCPT + 99 others); Wed, 12 Sep 2018 11:33:14 -0400 Received: from smtp.eu.citrix.com ([185.25.65.24]:5855 "EHLO SMTP.EU.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726782AbeILPdN (ORCPT ); Wed, 12 Sep 2018 11:33:13 -0400 X-IronPort-AV: E=Sophos;i="5.53,364,1531785600"; d="scan'208";a="78929444" Date: Wed, 12 Sep 2018 12:29:08 +0200 From: Roger Pau =?utf-8?B?TW9ubsOp?= To: Julien Grall CC: Jan Beulich , Jens Axboe , Konrad Rzeszutek Wilk , , , xen-devel , zhong jiang Subject: Re: [Xen-devel] [PATCH] drivers/block/xen-blkback/common.h: use DIV_ROUND_UP instead of reimplementing its function Message-ID: <20180912102908.4ls7vts55n2zfkdz@mac.bytemobile.com> References: <1536731100-56054-1-git-send-email-zhongjiang@huawei.com> <5B98CAE202000078001E79CC@prv1-mh.provo.novell.com> <20180912091350.6wuvt2jkvzg6wruo@mac.bytemobile.com> <20180912091639.oynlvdo6pghnqfvt@mac.bytemobile.com> <364bad2c-708e-6406-7b52-7bfef9d5dbe1@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <364bad2c-708e-6406-7b52-7bfef9d5dbe1@arm.com> User-Agent: NeoMutt/20180716 X-ClientProxiedBy: AMSPEX02CAS02.citrite.net (10.69.22.113) To AMSPEX02CL02.citrite.net (10.69.22.126) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 12, 2018 at 10:48:42AM +0100, Julien Grall wrote: > Hi, > > On 09/12/2018 10:16 AM, Roger Pau Monn? wrote: > > On Wed, Sep 12, 2018 at 11:13:50AM +0200, Roger Pau Monn? wrote: > > > Adding Julien how did the work to support XEN_PAGE_SIZE != PAGE_SIZE. > > > > > > On Wed, Sep 12, 2018 at 02:14:26AM -0600, Jan Beulich wrote: > > > > > > > On 12.09.18 at 07:45, wrote: > > > > > --- a/drivers/block/xen-blkback/common.h > > > > > +++ b/drivers/block/xen-blkback/common.h > > > > > @@ -65,7 +65,7 @@ > > > > > (XEN_PAGES_PER_INDIRECT_FRAME / XEN_PAGES_PER_SEGMENT) > > > > > #define MAX_INDIRECT_PAGES \ > > > > > - ((MAX_INDIRECT_SEGMENTS + SEGS_PER_INDIRECT_FRAME - 1)/SEGS_PER_INDIRECT_FRAME) > > > > > + DIV_ROUND_UP(MAX_INDIRECT_SEGMENTS, SEGS_PER_INDIRECT_FRAME) > > > > > #define INDIRECT_PAGES(_segs) DIV_ROUND_UP(_segs, XEN_PAGES_PER_INDIRECT_FRAME) > > > > > > > > My first reaction was to suggest > > > > > > > > #define MAX_INDIRECT_PAGES INDIRECT_PAGES(MAX_INDIRECT_SEGMENTS) > > > > > > > > but that wouldn't match what's there currently (note the two different > > > > divisors). I can't really decide whether that's just unfortunate naming > > > > of the two macros, or an actual bug. > > > > > > I think there's indeed a bug here. > > > > > > AFAICT, MAX_INDIRECT_PAGES should use XEN_PAGES_PER_INDIRECT_FRAME and > > > then it could be changed as Jan suggested. > > The problem is SEGS_PER_INDIRECT_FRAME has been miscalculated. So I think it > would be fine to use XEN_PAGES_PER_INDIRECT_FRAME in MAX_INDIRECT_PAGES. > > However the naming for XEN_PAGES_PER_INDIRECT_FRAME is misnamed. We return > number of a for segments per indirect frame. So I would rename to > SEGS_PER_INDIRECT_FRAME. I don't think I agree with this last part, SEGS_PER_INDIRECT_FRAME would have to take into account XEN_PAGES_PER_SEGMENT, and XEN_PAGES_PER_INDIRECT_FRAME doesn't. XEN_PAGES_PER_INDIRECT_FRAME currently returns the number of grant references per indirect page, but as I understand it a segment can use more than one grant reference, if for example the guest page size is 64KB. > > > > > > > Current MAX_INDIRECT_PAGES is misnamed and should instead be > > > MAX_INDIRECT_SEGS (which on x86 is exactly the same because PAGE_SIZE > > > == XEN_PAGE_SIZE). > > Looking at the usage: > > j = min(MAX_INDIRECT_PAGES, INDIRECT_PAGES(nr_segments)) > > Where j is used as the number of grant ref. So I don't think the variable is > misnamed here. Right, I agree that MAX_INDIRECT_PAGE/INDIRECT_PAGES is correct. Thanks, Roger.