From nobody Tue Feb 10 17:09:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1672659065; cv=none; d=zohomail.com; s=zohoarc; b=DgPL9tCpXl6y5HqF9+LXcduyTQckNCmXnUFpsv/i1nOh2c7CKSFIUEEbonEDSYUQTNsw/MeoCsC/NuZRUpGvSvUETubnDo1ucu9o9aLCrYZybiOqaXWrsr7+TGlDXvFhjuuKuPeunb6nbk7NTTuKbw3+fdkznY7PlrHRSWzpQXA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672659065; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Rg2tCcT43+3vmkteMsseQruJpL8Y15BaZz8dD3ypJ3M=; b=HgVb6B4SFB7st5sQufeU4nHYxR/LJdWq1omaMEDTH4yR1j+UKLMh4KXtQ9+3/9jvKIan3cqjvakanm4UXXiQpLqiJ6vqSNA8VbFige0/IsC8YRQ6i9VqFQus0DJ+hNsTXVQwU/sBXFPQkOypLmCPfLD/b4D9jrtQ3NhLeFkNtiE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672659065029114.38518473283091; Mon, 2 Jan 2023 03:31:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pCJ0a-000768-Eu; Mon, 02 Jan 2023 06:29:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pCJ0X-00075W-Bj for qemu-devel@nongnu.org; Mon, 02 Jan 2023 06:29:34 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pCJ0U-0007zM-JO for qemu-devel@nongnu.org; Mon, 02 Jan 2023 06:29:32 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-407-EOWNG0W2PGet9Xz5DFWUbg-1; Mon, 02 Jan 2023 06:29:28 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A30A5380670D; Mon, 2 Jan 2023 11:29:27 +0000 (UTC) Received: from t480s.redhat.com (unknown [10.39.193.209]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6188C40C2064; Mon, 2 Jan 2023 11:29:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672658969; 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=Rg2tCcT43+3vmkteMsseQruJpL8Y15BaZz8dD3ypJ3M=; b=MaDMfnE0QK76eJAD7CWv99+xfQB8gGc1XF5S8O5P52gALpW1dhqVNUbnLDknjFhJ5pBrhL 5WaMtzAN2tayr/gtF+OfF6a8fm5+PyV4mGlgAhXtTk6mRG8Phm/tK5Q4mtPzcnkmG/XZFw bhEKCR1LdxQPRO3nDG/TXabuuAtXWH4= X-MC-Unique: EOWNG0W2PGet9Xz5DFWUbg-1 From: David Hildenbrand To: qemu-devel@nongnu.org Cc: Igor Mammedov , "Michael S . Tsirkin" , Paolo Bonzini , David Hildenbrand , Chenyi Qiang , Michal Privoznik , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-stable@nongnu.org Subject: [GIT PULL 1/4] virtio-mem: Fix the bitmap index of the section offset Date: Mon, 2 Jan 2023 12:29:18 +0100 Message-Id: <20230102112921.68077-2-david@redhat.com> In-Reply-To: <20230102112921.68077-1-david@redhat.com> References: <20230102112921.68077-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=david@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1672659066580100005 Content-Type: text/plain; charset="utf-8" From: Chenyi Qiang vmem->bitmap indexes the memory region of the virtio-mem backend at a granularity of block_size. To calculate the index of target section offset, the block_size should be divided instead of the bitmap_size. Fixes: 2044969f0b ("virtio-mem: Implement RamDiscardManager interface") Signed-off-by: Chenyi Qiang Message-Id: <20221216062231.11181-1-chenyi.qiang@intel.com> Reviewed-by: David Hildenbrand Reviewed-by: Michael S. Tsirkin Cc: qemu-stable@nongnu.org Signed-off-by: David Hildenbrand --- hw/virtio/virtio-mem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index d96bde1fab..5c22c4b876 100644 --- a/hw/virtio/virtio-mem.c +++ b/hw/virtio/virtio-mem.c @@ -235,7 +235,7 @@ static int virtio_mem_for_each_plugged_section(const Vi= rtIOMEM *vmem, uint64_t offset, size; int ret =3D 0; =20 - first_bit =3D s->offset_within_region / vmem->bitmap_size; + first_bit =3D s->offset_within_region / vmem->block_size; first_bit =3D find_next_bit(vmem->bitmap, vmem->bitmap_size, first_bit= ); while (first_bit < vmem->bitmap_size) { MemoryRegionSection tmp =3D *s; @@ -267,7 +267,7 @@ static int virtio_mem_for_each_unplugged_section(const = VirtIOMEM *vmem, uint64_t offset, size; int ret =3D 0; =20 - first_bit =3D s->offset_within_region / vmem->bitmap_size; + first_bit =3D s->offset_within_region / vmem->block_size; first_bit =3D find_next_zero_bit(vmem->bitmap, vmem->bitmap_size, firs= t_bit); while (first_bit < vmem->bitmap_size) { MemoryRegionSection tmp =3D *s; --=20 2.39.0 From nobody Tue Feb 10 17:09:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1672659116; cv=none; d=zohomail.com; s=zohoarc; b=GBxuN/N4eCHQmQnK8dYxFgONHwVDUlkd6d67yoRaltgQGyclxCG0i00uCN2hTzOTMJRynBqBBHZV5leha1tzILnzWoygexSM/gz65ziSl7phZd+o02LMeG+icp3VkKUfc9hw78T6+aq6vO0uBnbWSiwE+BM7RoalcNG4NR+5qbA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672659116; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xHVsxT+wPYlq1BGkKqy9d1FLEscQXhY9hWbVKgk4v44=; b=lFdEIZVokyxL/KTms+wG1OgQo92JDSNDrrlEyiXqHeG9SXFqi3mlo/+Wdl8wvDdU5DBP1X9lrDCuuowOHrWzJdXIqWIY5ZZvVp3pUA1aAek0w+iPhZeykR8Q0ZMYcWGYbvRy/ZDJeS3bE4T+wmhVFP9bQUC8/SmTPWyXgCThpUw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672659116002561.7739162618315; Mon, 2 Jan 2023 03:31:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pCJ0b-00076r-Fi; Mon, 02 Jan 2023 06:29:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pCJ0Z-00075t-S3 for qemu-devel@nongnu.org; Mon, 02 Jan 2023 06:29:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pCJ0Y-0007zv-Ev for qemu-devel@nongnu.org; Mon, 02 Jan 2023 06:29:35 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-387-Flp4cJmBPkWbAfEgwEOzaw-1; Mon, 02 Jan 2023 06:29:30 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5059A85C064; Mon, 2 Jan 2023 11:29:30 +0000 (UTC) Received: from t480s.redhat.com (unknown [10.39.193.209]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F56440C2064; Mon, 2 Jan 2023 11:29:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672658973; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xHVsxT+wPYlq1BGkKqy9d1FLEscQXhY9hWbVKgk4v44=; b=QVw97YmjikJbqMpOLuW2D2Bbt+IDJpdYc1W4fh7Jo38HfeaFaIhAoQJN/CFadwdwrwfV+7 gz4G9u0lK6deDEoaWSN/6u+suqGBfIUsKIxLuwvm5Ufi58ZvG4nVVpKqA1Vbayb17FTUSd elezp977v4hkFANBqi99qVTLpy8pHLs= X-MC-Unique: Flp4cJmBPkWbAfEgwEOzaw-1 From: David Hildenbrand To: qemu-devel@nongnu.org Cc: Igor Mammedov , "Michael S . Tsirkin" , Paolo Bonzini , David Hildenbrand , Chenyi Qiang , Michal Privoznik , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-stable@nongnu.org Subject: [GIT PULL 2/4] virtio-mem: Fix the iterator variable in a vmem->rdl_list loop Date: Mon, 2 Jan 2023 12:29:19 +0100 Message-Id: <20230102112921.68077-3-david@redhat.com> In-Reply-To: <20230102112921.68077-1-david@redhat.com> References: <20230102112921.68077-1-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=david@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1672659116911100003 From: Chenyi Qiang It should be the variable rdl2 to revert the already-notified listeners. Fixes: 2044969f0b ("virtio-mem: Implement RamDiscardManager interface") Signed-off-by: Chenyi Qiang Message-Id: <20221228090312.17276-1-chenyi.qiang@intel.com> Cc: qemu-stable@nongnu.org Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: David Hildenbrand --- hw/virtio/virtio-mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index 5c22c4b876..2b0271442b 100644 --- a/hw/virtio/virtio-mem.c +++ b/hw/virtio/virtio-mem.c @@ -341,7 +341,7 @@ static int virtio_mem_notify_plug(VirtIOMEM *vmem, uint= 64_t offset, if (ret) { /* Notify all already-notified listeners. */ QLIST_FOREACH(rdl2, &vmem->rdl_list, next) { - MemoryRegionSection tmp =3D *rdl->section; + MemoryRegionSection tmp =3D *rdl2->section; =20 if (rdl2 =3D=3D rdl) { break; --=20 2.39.0 From nobody Tue Feb 10 17:09:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1672659080; cv=none; d=zohomail.com; s=zohoarc; b=eE/axcvgPBoOr3c5xczhC3GuulTwDvgTv9xTNfrY5oLpcRGYSy2ALMG7DfjOjBang4II2WaT2WGu49qIibYnXukHMqNESZY8TFTweLaMbKZSQu4JG2v+bZeO8I3ev7sgrL4/2YBd0aZqtsG+E4ke8vyMsFys4BZDGwZx4/b6UTE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672659080; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=QgBlRhIgOZOPZH7qzz7ywSmK47hj7d/oFGkRU7+f2PU=; b=Qq6L9gX98RHKsr3QFGpL1dazqZI7iB9zrka2wmuraEIJ2/jna6sFeJZkugBaVlnl5o+T5LxpMMS6/N3JX4kuLNmeI/kvqn6ELfTuJjeg4dqYai7m5iB8i599OCksCd3KTRB4OIawkYVQnsLLxWu5uYiMbdKnQ7IZJh0f5BK0Jow= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672659080614815.7095178099244; Mon, 2 Jan 2023 03:31:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pCJ0f-00078H-L9; Mon, 02 Jan 2023 06:29:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pCJ0d-00077u-Oh for qemu-devel@nongnu.org; Mon, 02 Jan 2023 06:29:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pCJ0c-00080U-8L for qemu-devel@nongnu.org; Mon, 02 Jan 2023 06:29:39 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-251-xo9k7LMUMHimf9Q_8vfmNQ-1; Mon, 02 Jan 2023 06:29:32 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EE30D85A588; Mon, 2 Jan 2023 11:29:31 +0000 (UTC) Received: from t480s.redhat.com (unknown [10.39.193.209]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F30D40C2064; Mon, 2 Jan 2023 11:29:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672658977; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QgBlRhIgOZOPZH7qzz7ywSmK47hj7d/oFGkRU7+f2PU=; b=jHR1jcQ34zwRlibolhyu6bBdii/UqUn60tdpdKvZCd6Chu7wn/6ugLZdfbc6ooaCBILGaq l/GWRkEYsTwrxsgeY/iRBBYtHV0G7rwFnPlHnQaMpFWObb0ST2+FP/FP/S17pBHaZltt++ D7XBY3Kg5nVZgAZey7YJvXgeWbc5IAk= X-MC-Unique: xo9k7LMUMHimf9Q_8vfmNQ-1 From: David Hildenbrand To: qemu-devel@nongnu.org Cc: Igor Mammedov , "Michael S . Tsirkin" , Paolo Bonzini , David Hildenbrand , Chenyi Qiang , Michal Privoznik , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [GIT PULL 3/4] virtio-mem: Fix typo in function name Date: Mon, 2 Jan 2023 12:29:20 +0100 Message-Id: <20230102112921.68077-4-david@redhat.com> In-Reply-To: <20230102112921.68077-1-david@redhat.com> References: <20230102112921.68077-1-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=david@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1672659082604100003 From: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20221228130956.80515-1-philmd@linaro.org> Signed-off-by: David Hildenbrand --- hw/virtio/virtio-mem.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index 2b0271442b..1ed1f5a4af 100644 --- a/hw/virtio/virtio-mem.c +++ b/hw/virtio/virtio-mem.c @@ -207,7 +207,7 @@ static int virtio_mem_for_each_unplugged_range(const Vi= rtIOMEM *vmem, void *arg, * * Returns false if the intersection is empty, otherwise returns true. */ -static bool virito_mem_intersect_memory_section(MemoryRegionSection *s, +static bool virtio_mem_intersect_memory_section(MemoryRegionSection *s, uint64_t offset, uint64_t = size) { uint64_t start =3D MAX(s->offset_within_region, offset); @@ -245,7 +245,7 @@ static int virtio_mem_for_each_plugged_section(const Vi= rtIOMEM *vmem, first_bit + 1) - 1; size =3D (last_bit - first_bit + 1) * vmem->block_size; =20 - if (!virito_mem_intersect_memory_section(&tmp, offset, size)) { + if (!virtio_mem_intersect_memory_section(&tmp, offset, size)) { break; } ret =3D cb(&tmp, arg); @@ -277,7 +277,7 @@ static int virtio_mem_for_each_unplugged_section(const = VirtIOMEM *vmem, first_bit + 1) - 1; size =3D (last_bit - first_bit + 1) * vmem->block_size; =20 - if (!virito_mem_intersect_memory_section(&tmp, offset, size)) { + if (!virtio_mem_intersect_memory_section(&tmp, offset, size)) { break; } ret =3D cb(&tmp, arg); @@ -313,7 +313,7 @@ static void virtio_mem_notify_unplug(VirtIOMEM *vmem, u= int64_t offset, QLIST_FOREACH(rdl, &vmem->rdl_list, next) { MemoryRegionSection tmp =3D *rdl->section; =20 - if (!virito_mem_intersect_memory_section(&tmp, offset, size)) { + if (!virtio_mem_intersect_memory_section(&tmp, offset, size)) { continue; } rdl->notify_discard(rdl, &tmp); @@ -329,7 +329,7 @@ static int virtio_mem_notify_plug(VirtIOMEM *vmem, uint= 64_t offset, QLIST_FOREACH(rdl, &vmem->rdl_list, next) { MemoryRegionSection tmp =3D *rdl->section; =20 - if (!virito_mem_intersect_memory_section(&tmp, offset, size)) { + if (!virtio_mem_intersect_memory_section(&tmp, offset, size)) { continue; } ret =3D rdl->notify_populate(rdl, &tmp); @@ -346,7 +346,7 @@ static int virtio_mem_notify_plug(VirtIOMEM *vmem, uint= 64_t offset, if (rdl2 =3D=3D rdl) { break; } - if (!virito_mem_intersect_memory_section(&tmp, offset, size)) { + if (!virtio_mem_intersect_memory_section(&tmp, offset, size)) { continue; } rdl2->notify_discard(rdl2, &tmp); --=20 2.39.0 From nobody Tue Feb 10 17:09:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1672659064; cv=none; d=zohomail.com; s=zohoarc; b=RX2mxtMApfxPJiAOAieMKxNbWC6oGECCiwHohJeyeokwgPTbivHG5NzAPr/8T9RUkXmfV/jZI6k1gtHrCxX8YEamcPWMDO6TmEbGkbWQx9NwGW8Kaj3Oz1u+VyxqjNfXmYN2CVuo++/30OZj9ZoD7UEAA7rNjsBEWEGwPVLJV0c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672659064; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KqnKwEYl8bSvsHZMLQ1pWuvrE1wRJieo2lU+F/vq3fo=; b=MAqBeP0M8arTPRqfaJak+1/Kk1ssBQwRVLE+Q46fFKk+zNOL+iqOg4XTtF3Xgy8Cv+MD5eXfHt00DOJHFMm8V+kEjMOmn0e/UxvVr2D7Q5RMFLIwNoBXsIUYGiOON1vCaYvY78cNVudqfOJRmpLcCq+TdPBKHlFwlPmLtC3et9s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672659064613257.84520476080115; Mon, 2 Jan 2023 03:31:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pCJ0h-00078U-DG; Mon, 02 Jan 2023 06:29:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pCJ0f-00078I-Ql for qemu-devel@nongnu.org; Mon, 02 Jan 2023 06:29:41 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pCJ0e-00080i-7l for qemu-devel@nongnu.org; Mon, 02 Jan 2023 06:29:41 -0500 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-333-e7d-ya0uOeOENOWE7Yxv2Q-1; Mon, 02 Jan 2023 06:29:34 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F3C633C0E205; Mon, 2 Jan 2023 11:29:33 +0000 (UTC) Received: from t480s.redhat.com (unknown [10.39.193.209]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5833F40C2064; Mon, 2 Jan 2023 11:29:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672658979; 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=KqnKwEYl8bSvsHZMLQ1pWuvrE1wRJieo2lU+F/vq3fo=; b=SRrTrY8KRopzTfUQpYuAtMGeU488ZUh/sTWv0Y6sEU3I3AbSoFqqhuiqV9MxKXDHe67+Oe sn9kx6nnxGjKYs2bxlAy1WqnOsdyEGOilzX3rpF8isUGuRlMs2X/3rASLXjLDMT0Z1gc/E m4kbTDUFr/A9q8Mm0GQJc3Pu4RDjBy8= X-MC-Unique: e7d-ya0uOeOENOWE7Yxv2Q-1 From: David Hildenbrand To: qemu-devel@nongnu.org Cc: Igor Mammedov , "Michael S . Tsirkin" , Paolo Bonzini , David Hildenbrand , Chenyi Qiang , Michal Privoznik , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [GIT PULL 4/4] hostmem: Honor multiple preferred nodes if possible Date: Mon, 2 Jan 2023 12:29:21 +0100 Message-Id: <20230102112921.68077-5-david@redhat.com> In-Reply-To: <20230102112921.68077-1-david@redhat.com> References: <20230102112921.68077-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=david@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1672659066590100007 Content-Type: text/plain; charset="utf-8" From: Michal Privoznik If a memory-backend is configured with mode HOST_MEM_POLICY_PREFERRED then host_memory_backend_memory_complete() calls mbind() as: mbind(..., MPOL_PREFERRED, nodemask, ...); Here, 'nodemask' is a bitmap of host NUMA nodes and corresponds to the .host-nodes attribute. Therefore, there can be multiple nodes specified. However, the documentation to MPOL_PREFERRED says: MPOL_PREFERRED This mode sets the preferred node for allocation. ... If nodemask specifies more than one node ID, the first node in the mask will be selected as the preferred node. Therefore, only the first node is honored and the rest is silently ignored. Well, with recent changes to the kernel and numactl we can do better. The Linux kernel added in v5.15 via commit cfcaa66f8032 ("mm/hugetlb: add support for mempolicy MPOL_PREFERRED_MANY") support for MPOL_PREFERRED_MANY, which accepts multiple preferred NUMA nodes instead. Then, numa_has_preferred_many() API was introduced to numactl (v2.0.15~26) allowing applications to query kernel support. Wiring this all together, we can pass MPOL_PREFERRED_MANY to the mbind() call instead and stop ignoring multiple nodes, silently. Signed-off-by: Michal Privoznik Message-Id: Reviewed-by: David Hildenbrand Signed-off-by: David Hildenbrand --- backends/hostmem.c | 19 +++++++++++++++++-- meson.build | 5 +++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/backends/hostmem.c b/backends/hostmem.c index 8640294c10..747e7838c0 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -23,7 +23,12 @@ =20 #ifdef CONFIG_NUMA #include +#include QEMU_BUILD_BUG_ON(HOST_MEM_POLICY_DEFAULT !=3D MPOL_DEFAULT); +/* + * HOST_MEM_POLICY_PREFERRED may either translate to MPOL_PREFERRED or + * MPOL_PREFERRED_MANY, see comments further below. + */ QEMU_BUILD_BUG_ON(HOST_MEM_POLICY_PREFERRED !=3D MPOL_PREFERRED); QEMU_BUILD_BUG_ON(HOST_MEM_POLICY_BIND !=3D MPOL_BIND); QEMU_BUILD_BUG_ON(HOST_MEM_POLICY_INTERLEAVE !=3D MPOL_INTERLEAVE); @@ -346,6 +351,7 @@ host_memory_backend_memory_complete(UserCreatable *uc, = Error **errp) * before mbind(). note: MPOL_MF_STRICT is ignored on hugepages so * this doesn't catch hugepage case. */ unsigned flags =3D MPOL_MF_STRICT | MPOL_MF_MOVE; + int mode =3D backend->policy; =20 /* check for invalid host-nodes and policies and give more verbose * error messages than mbind(). */ @@ -369,9 +375,18 @@ host_memory_backend_memory_complete(UserCreatable *uc,= Error **errp) BITS_TO_LONGS(MAX_NODES + 1) * sizeof(unsigned long)); assert(maxnode <=3D MAX_NODES); =20 +#ifdef HAVE_NUMA_HAS_PREFERRED_MANY + if (mode =3D=3D MPOL_PREFERRED && numa_has_preferred_many() > 0) { + /* + * Replace with MPOL_PREFERRED_MANY otherwise the mbind() below + * silently picks the first node. + */ + mode =3D MPOL_PREFERRED_MANY; + } +#endif + if (maxnode && - mbind(ptr, sz, backend->policy, backend->host_nodes, maxnode += 1, - flags)) { + mbind(ptr, sz, mode, backend->host_nodes, maxnode + 1, flags))= { if (backend->policy !=3D MPOL_DEFAULT || errno !=3D ENOSYS) { error_setg_errno(errp, errno, "cannot bind memory to host NUMA nodes"); diff --git a/meson.build b/meson.build index 4c6f8a674a..3f31db5963 100644 --- a/meson.build +++ b/meson.build @@ -1858,6 +1858,11 @@ config_host_data.set('CONFIG_LINUX_AIO', libaio.foun= d()) config_host_data.set('CONFIG_LINUX_IO_URING', linux_io_uring.found()) config_host_data.set('CONFIG_LIBPMEM', libpmem.found()) config_host_data.set('CONFIG_NUMA', numa.found()) +if numa.found() + config_host_data.set('HAVE_NUMA_HAS_PREFERRED_MANY', + cc.has_function('numa_has_preferred_many', + dependencies: numa)) +endif config_host_data.set('CONFIG_OPENGL', opengl.found()) config_host_data.set('CONFIG_PROFILER', get_option('profiler')) config_host_data.set('CONFIG_RBD', rbd.found()) --=20 2.39.0