Message ID | 20201112133815.13332-3-david@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <SRS0=Ki9e=ES=kvack.org=owner-linux-mm@kernel.org> Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D51F0921 for <patchwork-linux-mm@patchwork.kernel.org>; Thu, 12 Nov 2020 13:38:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7FE4222240 for <patchwork-linux-mm@patchwork.kernel.org>; Thu, 12 Nov 2020 13:38:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="QJjo0fAk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7FE4222240 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D70326B0071; Thu, 12 Nov 2020 08:38:35 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D237E6B0072; Thu, 12 Nov 2020 08:38:35 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B23D36B0073; Thu, 12 Nov 2020 08:38:35 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0248.hostedemail.com [216.40.44.248]) by kanga.kvack.org (Postfix) with ESMTP id 81FA46B0071 for <linux-mm@kvack.org>; Thu, 12 Nov 2020 08:38:35 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 21D131EE6 for <linux-mm@kvack.org>; Thu, 12 Nov 2020 13:38:35 +0000 (UTC) X-FDA: 77475870990.01.shirt57_211508427306 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id 048B910046464 for <linux-mm@kvack.org>; Thu, 12 Nov 2020 13:38:34 +0000 (UTC) X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,david@redhat.com,,RULES_HIT:30012:30054,0,RBL:216.205.24.124:@redhat.com:.lbl8.mailshell.net-62.18.0.100 64.10.201.10;04yfapp7oncp5u7g4jr9w3fpke7iwoc3mcxcommcxsip3drgujr8uuc4qq8nhce.zxxxhqjno6rsnpyeff6qih6t6u6ofcus9d94p6d5w9cs38p3g1cmtuq36crcmmb.6-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:ft,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:71,LUA_SUMMARY:none X-HE-Tag: shirt57_211508427306 X-Filterd-Recvd-Size: 3414 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf24.hostedemail.com (Postfix) with ESMTP for <linux-mm@kvack.org>; Thu, 12 Nov 2020 13:38:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605188313; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vWj2ryGZracq7Jb4f+d4SllYNO6XdToGqxK6IXTvhW8=; b=QJjo0fAk1/ENTNK8xDaHMbywO1FtKJuZcejP7XjqMQ8VYS9uTuMo9Uf+4gW+BLoRFJbBd7 uEkvPtwZgP2fxQcmqx9DpuxgcgeI+ydeQJ3lynm5TwZ67eh+BEgJb9Y24525ihaA33MJJP OOmipClcRiq2zzzg4IVfrwizVFqsItU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-589-biAF8QpOP6aQ2x_ScKgn_g-1; Thu, 12 Nov 2020 08:38:31 -0500 X-MC-Unique: biAF8QpOP6aQ2x_ScKgn_g-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 627D5809DEE; Thu, 12 Nov 2020 13:38:30 +0000 (UTC) Received: from t480s.redhat.com (ovpn-115-61.ams2.redhat.com [10.36.115.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id C80AE55765; Thu, 12 Nov 2020 13:38:28 +0000 (UTC) From: David Hildenbrand <david@redhat.com> To: linux-kernel@vger.kernel.org Cc: virtualization@lists.linux-foundation.org, linux-mm@kvack.org, "Michael S . Tsirkin" <mst@redhat.com>, David Hildenbrand <david@redhat.com>, Jason Wang <jasowang@redhat.com>, Pankaj Gupta <pankaj.gupta.linux@gmail.com> Subject: [PATCH v2 02/29] virtio-mem: more precise calculation in virtio_mem_mb_state_prepare_next_mb() Date: Thu, 12 Nov 2020 14:37:48 +0100 Message-Id: <20201112133815.13332-3-david@redhat.com> In-Reply-To: <20201112133815.13332-1-david@redhat.com> References: <20201112133815.13332-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Content-Transfer-Encoding: quoted-printable 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: <linux-mm.kvack.org> |
Series |
virtio-mem: Big Block Mode (BBM)
|
expand
|
diff --git a/drivers/virtio/virtio_mem.c b/drivers/virtio/virtio_mem.c index a37fd73588da..dee46865bae2 100644 --- a/drivers/virtio/virtio_mem.c +++ b/drivers/virtio/virtio_mem.c @@ -257,10 +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; - int old_pages = PFN_UP(old_bytes); - int new_pages = PFN_UP(new_bytes); + int old_pages = PFN_UP(vm->next_mb_id - vm->first_mb_id); + int new_pages = PFN_UP(vm->next_mb_id - vm->first_mb_id + 1); uint8_t *new_mb_state; if (vm->mb_state && old_pages == new_pages)
We actually need one byte less (next_mb_id is exclusive, first_mb_id is inclusive). While at it, compact the code. Cc: "Michael S. Tsirkin" <mst@redhat.com> Cc: Jason Wang <jasowang@redhat.com> Cc: Pankaj Gupta <pankaj.gupta.linux@gmail.com> Signed-off-by: David Hildenbrand <david@redhat.com> --- drivers/virtio/virtio_mem.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)