Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp458415ybc; Tue, 19 Nov 2019 04:12:58 -0800 (PST) X-Google-Smtp-Source: APXvYqxSgmzLZ+E05xR/GLyVFUGeSrtWvvzPXo1qmX15S7q3ryFbFaqALnP1RGYqvmNzKLqkaDsz X-Received: by 2002:a17:906:4098:: with SMTP id u24mr34212844ejj.220.1574165578639; Tue, 19 Nov 2019 04:12:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574165578; cv=none; d=google.com; s=arc-20160816; b=YbhlGTSAeq/OHb6B34HsFOaNCD2ExDGvRpzN4loYfex3Sc864XpRLVKdXjVhZIt7Ph uQSo9/xGJ70zqvRQ912MUQOhOMpeSfg1TVMUmSHzeiOgf2TeZuCmgkSNbABzvS/gZ20t IuuP80dIGZPhfdGxlzItC2FwQFXUibszyrBV9Kp+zPk3xFY3zFWwxh0Ag+6MfkRAqpKX RPE7kh1UpTVCUqY2AGHhEv7X0OXJtyVp6Y5DjOP9vkc4ZlZ72tdLC8x8xYK1T+4cnOFy GITzuyeX5z/KovsbIbl0Hncf0VOcPmOwU1dqpsa+RsnqzM5TKOfu0RwvawPhHV3CfMBQ X84g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :references:subject:cc:to:mime-version:user-agent:from:date :message-id; bh=fevbyX+9Ra9w8EZ1u3DJ16s/Snw9/1vlhGz6/fbYysU=; b=HE1CbflTEizZJMDbPMaEPCn8Iyn9UhFRsNUamdtwe/ICo4+3196QtqFaLPxRnj5Gfe Eh67PMGsDVLebE/k6XyFE2q0Bxo48Ygrua1qV4lawpZXvTCBQ3TTagHZGVnkukD20FgH i/NRYb1O9ozFkPHvX3mYYA0p3n35WHvFL9BpgbeNPlVl9MyTFwQk6++MA7mqA+fDad8s pxJxk5VHgpJVXTJYKUT4Rna/3yYe3jjeLCkXv0+rZWb84od8so3nY2v4MX6SwzsB495V W1eixbA8lwaOv4Hvg40HvrcSBXiTJrMt7WFI6DvZSyGR76k0sXTKxZ67ulpWj4ZgJxXB l8fQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n27si15285764ejl.272.2019.11.19.04.12.33; Tue, 19 Nov 2019 04:12:58 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727665AbfKSMLT (ORCPT + 99 others); Tue, 19 Nov 2019 07:11:19 -0500 Received: from mga06.intel.com ([134.134.136.31]:55483 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725798AbfKSMLT (ORCPT ); Tue, 19 Nov 2019 07:11:19 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Nov 2019 04:11:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,322,1569308400"; d="scan'208";a="357091891" Received: from unknown (HELO [10.239.13.7]) ([10.239.13.7]) by orsmga004.jf.intel.com with ESMTP; 19 Nov 2019 04:11:15 -0800 Message-ID: <5DD3DD7B.8000503@intel.com> Date: Tue, 19 Nov 2019 20:18:03 +0800 From: Wei Wang User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: "Michael S. Tsirkin" , linux-kernel@vger.kernel.org CC: Khazhismel Kumykov , Jason Wang , virtualization@lists.linux-foundation.org Subject: Re: [PATCH 1/2] virtio_balloon: name cleanups References: <20191119102838.39380-1-mst@redhat.com> In-Reply-To: <20191119102838.39380-1-mst@redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/19/2019 06:29 PM, Michael S. Tsirkin wrote: > free_page_order is a confusing name. It's not a page order > actually, it's the order of the block of memory we are hinting. > Rename to hint_block_order. Also, rename SIZE to BYTES > to make it clear it's the block size in bytes. > > Signed-off-by: Michael S. Tsirkin > --- > drivers/virtio/virtio_balloon.c | 24 ++++++++++++------------ > 1 file changed, 12 insertions(+), 12 deletions(-) > > diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c > index 65df40f261ab..b6a95cd28d9f 100644 > --- a/drivers/virtio/virtio_balloon.c > +++ b/drivers/virtio/virtio_balloon.c > @@ -32,10 +32,10 @@ > #define VIRTIO_BALLOON_FREE_PAGE_ALLOC_FLAG (__GFP_NORETRY | __GFP_NOWARN | \ > __GFP_NOMEMALLOC) > /* The order of free page blocks to report to host */ > -#define VIRTIO_BALLOON_FREE_PAGE_ORDER (MAX_ORDER - 1) > +#define VIRTIO_BALLOON_HINT_BLOCK_ORDER (MAX_ORDER - 1) > /* The size of a free page block in bytes */ > -#define VIRTIO_BALLOON_FREE_PAGE_SIZE \ > - (1 << (VIRTIO_BALLOON_FREE_PAGE_ORDER + PAGE_SHIFT)) > +#define VIRTIO_BALLOON_HINT_BLOCK_BYTES \ > + (1 << (VIRTIO_BALLOON_HINT_BLOCK_ORDER + PAGE_SHIFT)) > > #ifdef CONFIG_BALLOON_COMPACTION > static struct vfsmount *balloon_mnt; > @@ -380,7 +380,7 @@ static unsigned long return_free_pages_to_mm(struct virtio_balloon *vb, > if (!page) > break; > free_pages((unsigned long)page_address(page), > - VIRTIO_BALLOON_FREE_PAGE_ORDER); > + VIRTIO_BALLOON_HINT_BLOCK_ORDER); > } > vb->num_free_page_blocks -= num_returned; > spin_unlock_irq(&vb->free_page_list_lock); > @@ -582,7 +582,7 @@ static int get_free_page_and_send(struct virtio_balloon *vb) > ; > > page = alloc_pages(VIRTIO_BALLOON_FREE_PAGE_ALLOC_FLAG, > - VIRTIO_BALLOON_FREE_PAGE_ORDER); > + VIRTIO_BALLOON_HINT_BLOCK_ORDER); > /* > * When the allocation returns NULL, it indicates that we have got all > * the possible free pages, so return -EINTR to stop. > @@ -591,13 +591,13 @@ static int get_free_page_and_send(struct virtio_balloon *vb) > return -EINTR; > > p = page_address(page); > - sg_init_one(&sg, p, VIRTIO_BALLOON_FREE_PAGE_SIZE); > + sg_init_one(&sg, p, VIRTIO_BALLOON_HINT_BLOCK_BYTES); > /* There is always 1 entry reserved for the cmd id to use. */ > if (vq->num_free > 1) { > err = virtqueue_add_inbuf(vq, &sg, 1, p, GFP_KERNEL); > if (unlikely(err)) { > free_pages((unsigned long)p, > - VIRTIO_BALLOON_FREE_PAGE_ORDER); > + VIRTIO_BALLOON_HINT_BLOCK_ORDER); > return err; > } > virtqueue_kick(vq); > @@ -610,7 +610,7 @@ static int get_free_page_and_send(struct virtio_balloon *vb) > * The vq has no available entry to add this page block, so > * just free it. > */ > - free_pages((unsigned long)p, VIRTIO_BALLOON_FREE_PAGE_ORDER); > + free_pages((unsigned long)p, VIRTIO_BALLOON_HINT_BLOCK_ORDER); > } > > return 0; > @@ -765,11 +765,11 @@ static unsigned long shrink_free_pages(struct virtio_balloon *vb, > unsigned long blocks_to_free, blocks_freed; > > pages_to_free = round_up(pages_to_free, > - 1 << VIRTIO_BALLOON_FREE_PAGE_ORDER); > - blocks_to_free = pages_to_free >> VIRTIO_BALLOON_FREE_PAGE_ORDER; > + 1 << VIRTIO_BALLOON_HINT_BLOCK_ORDER); > + blocks_to_free = pages_to_free >> VIRTIO_BALLOON_HINT_BLOCK_ORDER; > blocks_freed = return_free_pages_to_mm(vb, blocks_to_free); > > - return blocks_freed << VIRTIO_BALLOON_FREE_PAGE_ORDER; > + return blocks_freed << VIRTIO_BALLOON_HINT_BLOCK_ORDER; > } > > static unsigned long leak_balloon_pages(struct virtio_balloon *vb, > @@ -825,7 +825,7 @@ static unsigned long virtio_balloon_shrinker_count(struct shrinker *shrinker, > unsigned long count; > > count = vb->num_pages / VIRTIO_BALLOON_PAGES_PER_PAGE; > - count += vb->num_free_page_blocks << VIRTIO_BALLOON_FREE_PAGE_ORDER; > + count += vb->num_free_page_blocks << VIRTIO_BALLOON_HINT_BLOCK_ORDER; > > return count; > } Reviewed-by: Wei Wang Best, Wei