From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C8DC93A3E7C for ; Mon, 20 Apr 2026 12:51:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776689470; cv=none; b=P8bqiaRzgvbjvSswprlqDClKhRn3ARtwib6L8N9fWnN6Prd6FDjKCv73t5pTBeDFsYdtcL/ZkAJFLv4dyjTupF3v2+vAaRdN+XAO93uZkx6wU3qSj+xwcxjpvnjHGhOVletN4KAMZh8oNh6nZ+++3J7oRcgxN5iVwkYhDHgtDEE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776689470; c=relaxed/simple; bh=AZKQuPir2M6D9nuVJhXEkkcoZRJ4ZuK7KdkVVibbYjs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hi+2zqL9ejwwtPtClUJFvF/K6hP/DwHpdlvIe+Ivo0CwTTS0y5rn0hGiz7mxnln0HlEhRa0FQw/mrIRC/bsta6T++FyLm9cxtctrFR3tDWqaz/LPIGZBAsqgdlNNdol4hFC7FgJvQLJsHexZuKuWod0jVTbpb/fNvCDt/SkR0Dg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=IRxf3kpC; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=Kds7MWNb; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="IRxf3kpC"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="Kds7MWNb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776689468; 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: in-reply-to:in-reply-to:references:references; bh=tQ3NH90R6jD51b/2nlDfTNF+z8a8ZXOca/8W5MzOPpI=; b=IRxf3kpC5eh5K/2DRkzb6cZD0cDaIqe0HKsiL4aTPH8lXQsJYu3TBV33tfLgjv319KJmEO D7KbQBzLpP5MZxSY+ov+NMsr3FqY7nOdWJIMcXH/6tnsa9cT8Gyjy787RQz+KNw2lMPFF4 ohRKCGoFdw0bDBTFZU54rF7z1oM1nx8= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-351-igdjPvjuOG6XNip2LbtjnA-1; Mon, 20 Apr 2026 08:51:07 -0400 X-MC-Unique: igdjPvjuOG6XNip2LbtjnA-1 X-Mimecast-MFC-AGG-ID: igdjPvjuOG6XNip2LbtjnA_1776689465 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-488bd1ee9e7so21560995e9.1 for ; Mon, 20 Apr 2026 05:51:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1776689464; x=1777294264; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=tQ3NH90R6jD51b/2nlDfTNF+z8a8ZXOca/8W5MzOPpI=; b=Kds7MWNbhyg4fvN4fI4B+bBfzy4+FsiKkRqJaxnhe3yrpBObLVnTBQ1XdaeGqgIYAY YK/j4MdNJvvjfzlmMEMac76vvX4rjvLkW42wYSpvuKbgP5iH+7H8JT2ZKGr0Et8F3sT3 7ToI3dknzTTyou/cIpCoJUjFWvCNYSJ8HWtREmBGsiSObwYfefIiWNDIIeiB9x8l6hb7 BMPAyeGrNvujxyG/z5ERCtazCLX9a/fP0rFAuIy2fcNoOd8PM6O1wJawF2os5a6aFfE2 MhjdTEhJK/Onqz+S2ruKRD4IroSOR3I4j4v8fqVYJh2YXOx1JpoOCPH58m57uEB5kg4a zxUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776689464; x=1777294264; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tQ3NH90R6jD51b/2nlDfTNF+z8a8ZXOca/8W5MzOPpI=; b=kNdcqd1XN5vXh+vT6bfLX3+9YK8q+9NzEt8dCaXxBl220dm+CXNVtOH58sBsmqtsyq ZdCEII50tZs00LfHe/0iBf439G2D7yOLJyjP6qGLahGrftc5XM4qTalw8rMTRN4Cu4x8 G/TwLD2K0Oz3yvsvofhSJaMI1o9p4cEtFbwAK2JU1LAIfrJIPdpl4bDwxmDIP2VgQSA1 1B0z0AIKs5sJp6jyhQF2EzcTRkQlB+XGhDyqN21Z2P3bhKoxchB7BL0mnrSwwQOWNwiv Ts+2wPtwflQPsj7crASaRQcgQMaRyv6+T/lvC5G8JhcJoFTphj6yvjnryKJ7CB2k6xfX 4WSg== X-Gm-Message-State: AOJu0YyA/4T+wWcHRS4jcAPSEAzH36tCikitq5POWCjWXsPw6RJebzN7 vQgrDBkdr3nfjLExRBqhNvtDdVI2DWOhbYb+VUGc17h7fzU6xrb5uwEVvF8axKweud/nWqY0Ton brvuuGm6tYsuk3Ugp1YpgxRzEtpOHhqi+uYQZb9Pyi1SbdWVUbJN+/bfr2ch3gdZnGsF4ll5PJB 1fltzn8Eu1oW2DoZwnyHkycbO0u6fWyC+m9kYcv8TyzDQ= X-Gm-Gg: AeBDievGeAwTi+ivvOUj/gd4PW1GwFp4DSBoyuaPLDCo65DFC8FbC/JJGW0stS9WpHH uTStf7dzfB3NCOz1mcFidd7LRPeUc7Y+tBGiQZw9Ez90mZkkB6qmyd1HiIO1vlEWDTsQ+aaVeRr XZLMHbwqQn0Igq9Md5SgggTcmmbRHr1qu6BfL2qilnEm+o8Ri4XrImCBqQxLqRNEKecUMZQye3k nbQaI4iBS6YslAz7zDloOSYKeXgwRlgEJv1/BWlUQEmOU3TID/aKoXogW2afRpH/rrh7cvuCBgS Le9MPAH/lsegM5LwcEFP6Tl37hMLWXE9boWhuzjzkepgZjtTFFMImf/oj0g2cFamFNlXNFczNAM nkA+IFPeWJ0L85KVflzkBAl+Ym4a+je4kXO2Q0m5vmU5ox04wju/ofA== X-Received: by 2002:a05:600c:3546:b0:488:81b1:ae36 with SMTP id 5b1f17b1804b1-488fb7880camr196781265e9.23.1776689464298; Mon, 20 Apr 2026 05:51:04 -0700 (PDT) X-Received: by 2002:a05:600c:3546:b0:488:81b1:ae36 with SMTP id 5b1f17b1804b1-488fb7880camr196780585e9.23.1776689463650; Mon, 20 Apr 2026 05:51:03 -0700 (PDT) Received: from redhat.com (IGLD-80-230-25-21.inter.net.il. [80.230.25.21]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-489393ddd69sm12665675e9.10.2026.04.20.05.51.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2026 05:51:03 -0700 (PDT) Date: Mon, 20 Apr 2026 08:51:01 -0400 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Cc: Andrew Morton , David Hildenbrand , Vlastimil Babka , Brendan Jackman , Michal Hocko , Suren Baghdasaryan , Jason Wang , Andrea Arcangeli , linux-mm@kvack.org, virtualization@lists.linux.dev, Xuan Zhuo , Eugenio =?utf-8?B?UMOpcmV6?= Subject: [PATCH RFC v2 15/18] virtio_balloon: add host_zeroes_pages module parameter Message-ID: <0667676f47ce42c1b9086dc80987773d96f73861.1776689093.git.mst@redhat.com> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Add a module parameter to opt in to the pre-zeroed page optimization. A proper virtio feature flag is needed before this can be merged. insmod virtio_balloon.ko host_zeroes_pages=1 When host_zeroes_pages is set, callers skip folio_zero_user() for pages that are known to have been zeroed by the host. This is safe on cache-aliasing architectures because the hypervisor invalidates guest cache lines when reclaiming page backing (e.g. MADV_DONTNEED), so no stale cache state exists when the guest re-maps the page. Signed-off-by: Michael S. Tsirkin Assisted-by: Claude:claude-opus-4-6 Assisted-by: cursor-agent:GPT-5.4-xhigh --- drivers/virtio/virtio_balloon.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index d1fbc8fe8470..2e524bf6f934 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -19,6 +19,11 @@ #include #include +static bool host_zeroes_pages; +module_param(host_zeroes_pages, bool, 0444); +MODULE_PARM_DESC(host_zeroes_pages, + "Host zeroes reported pages, skip guest re-zeroing"); + /* * Balloon device works in 4K page units. So each page is pointed to by * multiple balloon pages. All memory counters in this driver are in balloon @@ -1039,6 +1044,7 @@ static int virtballoon_probe(struct virtio_device *vdev) vb->pr_dev_info.order = 5; #endif + vb->pr_dev_info.host_zeroes_pages = host_zeroes_pages; err = page_reporting_register(&vb->pr_dev_info); if (err) goto out_unregister_oom; -- MST