Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp594135pxu; Thu, 15 Oct 2020 11:25:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjR2IByMnPe+/eQWYNTiPZX9y55x5APUkJQGhvgeLZZuNrf4opd3t9Kag630DzV85bNMq5 X-Received: by 2002:a17:907:1010:: with SMTP id ox16mr5997325ejb.379.1602786307920; Thu, 15 Oct 2020 11:25:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602786307; cv=none; d=google.com; s=arc-20160816; b=UOwkaMyewv1OMBbcPKRykV0pkkXzUj1t982dQAWoYq5LyDjiaKxqiJz4XrBX7X3Sam ZqCz4SlEUEtnynXfEaWOjimQMp4gyaelZvyY2mKSVPwnTXIC5VcH05p5QEcsRVgnY1uz 05dRltrXx6eU8DSMFEZL49v07Ns1dmpGcj9qTBCVGSzeqScK+bdyTSmG2jLLG3lwTYyM oeu07pO+J8WOlVFlmWM1e0gRe8Nmbx7crwYSXnbocC6dYwU36ZW3BQSBf8gMAJOGCAtX xo64Nvb+OnQb7HAnnAJNahkp2XXkmlfxC1kkkbSw+KVyI1irQ5TSnK7FptZ2h7Jns1xM XtPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date; bh=N7O8/mznACA7Rt/76Lu5pAC9Gj4KG5mVUbZRCQuc8bY=; b=lGk4HCO9R1352ZzLGq9sfM0gH1LAVMPZfpyLf6ONegzo2W48Bpqaje6llbBfn4UeBM /HMUdoGEQXFJmViObLIIHa/52Ez4csxTvdOlvwNwbs9a/jVQyzSjwupXHN/lteEf0OlQ 5CmO3iuLoU7gxXAm+RMRykF553xl9zq4K3B/Q7lM+oZCn7WJhi1FkgCkewHsU1Ha8JF/ 2y7q2i18C3OSSAaQ0TSwjWsJvnrEI8HK3JpDHV9egguxSnIgkU0HYnSz8AB28S/yIDlh 5ulyFlTzLPfC48X626ExS0hWz7Hi78ZFWvSAuujHzpsD1i3wDwwUaAJm4TSQSy+G/S97 rY3g== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dp1si1994805ejc.286.2020.10.15.11.24.38; Thu, 15 Oct 2020 11:25:07 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729136AbgJOIcg (ORCPT + 99 others); Thu, 15 Oct 2020 04:32:36 -0400 Received: from out30-54.freemail.mail.aliyun.com ([115.124.30.54]:44903 "EHLO out30-54.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728436AbgJOIcg (ORCPT ); Thu, 15 Oct 2020 04:32:36 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R621e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04357;MF=richard.weiyang@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0UC5T.KF_1602750754; Received: from localhost(mailfrom:richard.weiyang@linux.alibaba.com fp:SMTPD_---0UC5T.KF_1602750754) by smtp.aliyun-inc.com(127.0.0.1); Thu, 15 Oct 2020 16:32:34 +0800 Date: Thu, 15 Oct 2020 16:32:34 +0800 From: Wei Yang To: David Hildenbrand Cc: 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 06/29] virtio-mem: generalize virtio_mem_owned_mb() Message-ID: <20201015083234.GF86495@L-31X9LVDL-1304.local> Reply-To: Wei Yang References: <20201012125323.17509-1-david@redhat.com> <20201012125323.17509-7-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201012125323.17509-7-david@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 12, 2020 at 02:53:00PM +0200, David Hildenbrand wrote: >Avoid using memory block ids. Rename it to virtio_mem_contains_range(). > >Cc: "Michael S. Tsirkin" >Cc: Jason Wang >Cc: Pankaj Gupta >Signed-off-by: David Hildenbrand >--- > drivers/virtio/virtio_mem.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > >diff --git a/drivers/virtio/virtio_mem.c b/drivers/virtio/virtio_mem.c >index 6bbd1cfd10d3..821143db14fe 100644 >--- a/drivers/virtio/virtio_mem.c >+++ b/drivers/virtio/virtio_mem.c >@@ -500,12 +500,13 @@ static bool virtio_mem_overlaps_range(struct virtio_mem *vm, > } > > /* >- * Test if a virtio-mem device owns a memory block. Can be called from >+ * Test if a virtio-mem device contains a given range. Can be called from > * (notifier) callbacks lockless. > */ >-static bool virtio_mem_owned_mb(struct virtio_mem *vm, unsigned long mb_id) >+static bool virtio_mem_contains_range(struct virtio_mem *vm, uint64_t start, >+ uint64_t size) > { >- return mb_id >= vm->first_mb_id && mb_id <= vm->last_mb_id; >+ return start >= vm->addr && start + size <= vm->addr + vm->region_size; Do we have some reason to do this change? > } > > static int virtio_mem_notify_going_online(struct virtio_mem *vm, >@@ -800,7 +801,7 @@ static void virtio_mem_online_page_cb(struct page *page, unsigned int order) > */ > rcu_read_lock(); > list_for_each_entry_rcu(vm, &virtio_mem_devices, next) { >- if (!virtio_mem_owned_mb(vm, mb_id)) >+ if (!virtio_mem_contains_range(vm, addr, PFN_PHYS(1 << order))) > continue; > > sb_id = virtio_mem_phys_to_sb_id(vm, addr); >-- >2.26.2 -- Wei Yang Help you, Help me