From patchwork Thu Nov 12 13:37:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 11900257 Return-Path: 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 2CE9F921 for ; Thu, 12 Nov 2020 13:39:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D3C2B22248 for ; Thu, 12 Nov 2020 13:39:07 +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="dS9s3rYZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D3C2B22248 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 13AF16B0081; Thu, 12 Nov 2020 08:39:05 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0ED396B0082; Thu, 12 Nov 2020 08:39:05 -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 EF5C16B0083; Thu, 12 Nov 2020 08:39:04 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0024.hostedemail.com [216.40.44.24]) by kanga.kvack.org (Postfix) with ESMTP id B0C696B0081 for ; Thu, 12 Nov 2020 08:39:04 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 5B63C180AD801 for ; Thu, 12 Nov 2020 13:39:04 +0000 (UTC) X-FDA: 77475872208.19.team68_3a0213527306 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id 33E531AD1B3 for ; Thu, 12 Nov 2020 13:39:04 +0000 (UTC) X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,david@redhat.com,,RULES_HIT:30054:30070,0,RBL:63.128.21.124:@redhat.com:.lbl8.mailshell.net-62.18.0.100 64.10.201.10;04ygaguhjpsbeq648kwyg4eb66cqbycezpib74kwgu1thef5ipkrcephjktn6hf.5dz99fjop4ae38do7x48acyerhm1tun36z51qatsyu3f9wnpmpm891uydkn73gb.o-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:70,LUA_SUMMARY:none X-HE-Tag: team68_3a0213527306 X-Filterd-Recvd-Size: 3901 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf11.hostedemail.com (Postfix) with ESMTP for ; Thu, 12 Nov 2020 13:39:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605188343; 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=Vdbw4BBnAlXbecdd3kz0Gf6U85wgo73x2VHWlqh8gqU=; b=dS9s3rYZOxh+L5NRp8y9k6L5oOZ/Qyqym9W3YYJM8qZNLAokKsCis8WPCEsMQ1/rVYJECP 1yt41Bfze4XOLel4UH0il4hZaXYqoK88l0Mb7krqpytE89yPf4Z9crhSfawQMWDUuewDLa Nbk2ZWMDa5asAHz8uJZQ4B7eTfiL+8g= 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-116-BYRt4WzrNyuEdueCGAxQeA-1; Thu, 12 Nov 2020 08:39:01 -0500 X-MC-Unique: BYRt4WzrNyuEdueCGAxQeA-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 7F976801FD4; Thu, 12 Nov 2020 13:39:00 +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 AF55075132; Thu, 12 Nov 2020 13:38:55 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: virtualization@lists.linux-foundation.org, linux-mm@kvack.org, "Michael S . Tsirkin" , David Hildenbrand , Pankaj Gupta , Jason Wang Subject: [PATCH v2 12/29] virtio-mem: generalize virtio_mem_owned_mb() Date: Thu, 12 Nov 2020 14:37:58 +0100 Message-Id: <20201112133815.13332-13-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 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: Avoid using memory block ids. Rename it to virtio_mem_contains_range(). This is a preparation for Big Block Mode (BBM). Reviewed-by: Pankaj Gupta 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 3731097cd9e8..2193c5172195 100644 --- a/drivers/virtio/virtio_mem.c +++ b/drivers/virtio/virtio_mem.c @@ -512,12 +512,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; } static int virtio_mem_notify_going_online(struct virtio_mem *vm, @@ -871,7 +872,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);