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=-9.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=ham 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 131E5C433E7 for ; Thu, 15 Oct 2020 10:00:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5AE482222E for ; Thu, 15 Oct 2020 10:00:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5AE482222E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id AA4E76B008A; Thu, 15 Oct 2020 06:00:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A31276B0096; Thu, 15 Oct 2020 06:00:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9288D6B008A; Thu, 15 Oct 2020 06:00:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0043.hostedemail.com [216.40.44.43]) by kanga.kvack.org (Postfix) with ESMTP id 616C06B008A for ; Thu, 15 Oct 2020 06:00:16 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id D35D982499A8 for ; Thu, 15 Oct 2020 10:00:15 +0000 (UTC) X-FDA: 77373714390.21.linen10_5e06f6527213 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id B0856180442C3 for ; Thu, 15 Oct 2020 10:00:15 +0000 (UTC) X-HE-Tag: linen10_5e06f6527213 X-Filterd-Recvd-Size: 3708 Received: from out30-133.freemail.mail.aliyun.com (out30-133.freemail.mail.aliyun.com [115.124.30.133]) by imf05.hostedemail.com (Postfix) with ESMTP for ; Thu, 15 Oct 2020 10:00:14 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04426;MF=richard.weiyang@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0UC62.Wb_1602756009; Received: from localhost(mailfrom:richard.weiyang@linux.alibaba.com fp:SMTPD_---0UC62.Wb_1602756009) by smtp.aliyun-inc.com(127.0.0.1); Thu, 15 Oct 2020 18:00:09 +0800 Date: Thu, 15 Oct 2020 18:00:09 +0800 From: Wei Yang To: David Hildenbrand Cc: Wei Yang , linux-kernel@vger.kernel.org, linux-mm@kvack.org, virtualization@lists.linux-foundation.org, Andrew Morton , "Michael S . Tsirkin" , Jason Wang , Pankaj Gupta Subject: Re: [PATCH v1 02/29] virtio-mem: simplify calculation in virtio_mem_mb_state_prepare_next_mb() Message-ID: <20201015100009.GH86495@L-31X9LVDL-1304.local> Reply-To: Wei Yang References: <20201012125323.17509-1-david@redhat.com> <20201012125323.17509-3-david@redhat.com> <20201015040204.GB86495@L-31X9LVDL-1304.local> <730d6536-f6a6-72e5-327f-00ce1224b730@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <730d6536-f6a6-72e5-327f-00ce1224b730@redhat.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Oct 15, 2020 at 10:00:15AM +0200, David Hildenbrand wrote: >On 15.10.20 06:02, Wei Yang wrote: >> On Mon, Oct 12, 2020 at 02:52:56PM +0200, David Hildenbrand wrote: >>> We actually need one byte less (next_mb_id is exclusive, first_mb_id is >>> inclusive). Simplify. >>> >>> Cc: "Michael S. Tsirkin" >>> Cc: Jason Wang >>> Cc: Pankaj Gupta >>> Signed-off-by: David Hildenbrand >>> --- >>> drivers/virtio/virtio_mem.c | 4 ++-- >>> 1 file changed, 2 insertions(+), 2 deletions(-) >>> >>> diff --git a/drivers/virtio/virtio_mem.c b/drivers/virtio/virtio_mem.c >>> index a1f5bf7a571a..670b3faf412d 100644 >>> --- a/drivers/virtio/virtio_mem.c >>> +++ b/drivers/virtio/virtio_mem.c >>> @@ -257,8 +257,8 @@ static enum virtio_mem_mb_state virtio_mem_mb_get_state(struct virtio_mem *vm, >>> */ >>> static int virtio_mem_mb_state_prepare_next_mb(struct virtio_mem *vm) >>> { >>> - unsigned long old_bytes = vm->next_mb_id - vm->first_mb_id + 1; >>> - unsigned long new_bytes = vm->next_mb_id - vm->first_mb_id + 2; >>> + unsigned long old_bytes = vm->next_mb_id - vm->first_mb_id; >>> + unsigned long new_bytes = old_bytes + 1; >> >> This is correct. >> >> So this looks more like a fix? > >We allocate an additional new page "one memory block too early". > >So we would allocate the first page for blocks 0..510, and already >allocate the second page with block 511, although we could have fit it >into the first page. Block 512 will then find that the second page is >already there and simply use the second page. > >So as we do it consistently, nothing will go wrong - that's why I >avoided using the "fix" terminology. > Yes, my feeling is this is not a simplification. Instead this is a more precise calculation. How about use this subject? virtio-mem: more precise calculation in virtio_mem_mb_state_prepare_next_mb() >Thanks! > >-- >Thanks, > >David / dhildenb -- Wei Yang Help you, Help me