Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp735024pxu; Thu, 15 Oct 2020 15:24:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyiVbqp0jurH5xGZK+UifAEwQq/3y/02zHvMExV3IBVv3JpU7dQGMvglV8Nm8tLHYTJARLP X-Received: by 2002:a17:906:590d:: with SMTP id h13mr584139ejq.226.1602800697359; Thu, 15 Oct 2020 15:24:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602800697; cv=none; d=google.com; s=arc-20160816; b=rkRsa01BPCIDEIbmyT/6uxUk0y4WVPEgUrmg78poQ0HXMABZZs/dat238yuB/W5cXR D9S1ip4MjK8LaFYDz8/6noikRrJaacUYOjHXi1JeVk7mFqUJIJdLJu4rgWbuq+XqtIAI L5pUeD7M34qoHDRib1xuNsOmd8lJ05O/BOKmv4KGDJkD1XpDJFUHzHNqRnZO6qQOzFuo mVL+RS4OnIWrAmpNKBm8h9I3Hqjhg7VF0F2nqy2UDP5WErLi9OXFpYk/+xvvuTmUwFDY l2VYXadVn5lJBTzChIfqvq29zgwAL7UfuATuDSNNygVUOdQmt2WsJf1JuY6GtBlj62sm 8LOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=/jxSiXUFHPKoVWvB4Kho7bLX6BXoNLesB/In+yGJN0M=; b=Hmj/9Q4rbwNl/1+/EF1nFAZs6iiETmqKRhMrdLHdn1KxzX1SSmjqepMD5TwZb3vi0G u/00vBdTx5/R1FQOy6bX6t7U7c1f+do9Yke6IdG8Uo07H+9Qd+ng5NI+qK+d2Wq3EVUX i7itBnFRrg6THCMaQsmBUOSqZnagy6r2RgbxVwKl+7QkpJ0dxwBA7JuFZpCQCnlI1uRn Fe7ehUzG0M4rlIovZufpvNvKUtrtIlr/UWLoN+x45PzFsoIah1dNxWUejWTrwh2mssRB bcPboJdJnQ8hLMyUOxHpOByJ2DlA0HqW2ZTQgRVHa+nszUWRQw88P31/Nb7ywbVTjtzD kPtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=m6ii6kwg; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l23si306355ejb.488.2020.10.15.15.24.35; Thu, 15 Oct 2020 15:24:57 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=m6ii6kwg; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732606AbgJOUaW (ORCPT + 99 others); Thu, 15 Oct 2020 16:30:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731040AbgJOUaW (ORCPT ); Thu, 15 Oct 2020 16:30:22 -0400 Received: from mail-il1-x144.google.com (mail-il1-x144.google.com [IPv6:2607:f8b0:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 852B9C061755 for ; Thu, 15 Oct 2020 13:30:21 -0700 (PDT) Received: by mail-il1-x144.google.com with SMTP id y16so6260465ila.7 for ; Thu, 15 Oct 2020 13:30:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/jxSiXUFHPKoVWvB4Kho7bLX6BXoNLesB/In+yGJN0M=; b=m6ii6kwgw2MTT+gIs1qNafQgE+1wC+HcGAAG5DVQ5N3c3MvWoIXwbtkLrgEcdSgU0l cSfpLzmsmliwsAlSTufVFgaFTuvLQUpxLV4emLR/kOzjLAQ5hmhKZOeJsXwwdxtXlOgS 0TkZmDN3hxDZfKMgysOzQzhim1wrGGbaPvEhOtFYO4Ty6Orh+Ze0lHxl7/XoSWBSs1HY +2vxlJbtwJUYtT2unuAe5so9kivgiAD0exdzlHNc9wcNnlv8K+3adk5y7C1N0sUz2yM3 Fgodn3vHy8t6uW/pyIjWMYNgGM11tmEJ2q4iTfDBaeS7izoo39dvGzZSqBJ4vlOjlLeQ 8/ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/jxSiXUFHPKoVWvB4Kho7bLX6BXoNLesB/In+yGJN0M=; b=qbVkzB2Tc6k+9NJQNoq6aGbf8J/y9Oqaa9FN4WJW2MRAtn/t0bFgbkjHXWPPKSzdpI unqkQQP6EwQyd+ZCci10qagAPrLJ5NAJumi3lzlr5/UvLzfSr5JStOaHADyjbR6cbY9P 25bYmFODo1PfiS5M66x8KuF9FPFjdoMsv/vFAE4eYWmuuQT/PY+FZsWGF0gZPt/P8cDL LY7c//hUQ404IUX3wdkJy0GbmFqI9TosQtxdYQ8CeQDhU4SPg43LfWHqhB1oFBO887NB e595anj9j5tV/Af7Ys0NTiz6c7kWNlCPkZedruuGjNQb35V8qM1Vpp0kpY6qDIgNY26r EYyA== X-Gm-Message-State: AOAM5335bvWrNOAV9d9YKKy1NRCUmYDN4q47P8zlyiTKPbCu4eQl3XHH OgPemeYBJ90IEClgIGPlJLo3RQhswdsEScvRaYs= X-Received: by 2002:a92:874a:: with SMTP id d10mr274971ilm.163.1602793820977; Thu, 15 Oct 2020 13:30:20 -0700 (PDT) MIME-Version: 1.0 References: <20201012125323.17509-1-david@redhat.com> <20201012125323.17509-7-david@redhat.com> In-Reply-To: <20201012125323.17509-7-david@redhat.com> From: Pankaj Gupta Date: Thu, 15 Oct 2020 22:30:09 +0200 Message-ID: Subject: Re: [PATCH v1 06/29] virtio-mem: generalize virtio_mem_owned_mb() To: David Hildenbrand Cc: LKML , Linux MM , virtualization@lists.linux-foundation.org, Andrew Morton , "Michael S . Tsirkin" , Jason Wang Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > 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; > } > > 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); Looks good. Reviewed-by: Pankaj Gupta