Received: by 2002:ab2:3c46:0:b0:1f5:f2ab:c469 with SMTP id x6csp137287lqf; Fri, 26 Apr 2024 01:59:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX6lJrUFkLDPdAgJjuXRDyeW5RvofM0mWDTcCjAh341GRQwXbSMWRJhyBdHf103f9ba4v4tlkrXW2+oWtO8OJuIuFir5HmkxiKNolkWzQ== X-Google-Smtp-Source: AGHT+IGJtamt9IDiwho1IZYd4xPnAK2cZU7fUizklyhokuu/lTfjdLs6e1a54oUHw5aNBOfrv7tR X-Received: by 2002:ac2:5937:0:b0:51c:37e6:6bd with SMTP id v23-20020ac25937000000b0051c37e606bdmr1183271lfi.28.1714121950927; Fri, 26 Apr 2024 01:59:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714121950; cv=pass; d=google.com; s=arc-20160816; b=OgEwFKjSXUlbEVcsflfJR04AShxOL82e4jU2HV+V4bD4jC2RkLRTT006rgey9cjcV0 9pIQ3ysMsqVAX0879Llo8dcq2sGXtpTddwWDDN1ayPwUBdmonjAdtJLlJJmTZzDFw8Ba AaZqLQIpn/mPNFW5Lz8mZNsPqM7ECtI3HpFrFVdOqQyMKtPzxuU4bMn1baoIOdmDWDaY EAVRqNwbtFCUPJasYFSBE4gq0qQf4OqizZw1VVpAmoFJndC48cQslmX8BsbjRXzX9R1E gcR8EkzcR+IL4VofD5UNhoqXJV+adJZ7S5T7j62XO0Xqh78Kxn9bZ1DVIGdqI8+DBD1N x6zw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:organization:autocrypt :content-language:from:references:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=bRPXKQ+KIC0ZxHv4USsHQnv5JvvbpfCYVb/U1bJ6Y7s=; fh=I3CH89AR5J+wpAdnfbYDXv3lJnFTSw3HQka8qc2OGKU=; b=kAkirk41GYqG2dyBzSg72doCZEBpvPUWdkpF1tOR/vv0MMb8BN2I/oKTT3h7Dh7sBu u7bJYPMbF9GyMy4kSzLgZ+QYEm+HcC5jrMbphE8GCVipYC1sGFbgCfRZ0l7ASYrBSevH 75u8D0Gdd6Cat2JXFgEQaV23KbAeBB73kXNIyDsJcweU9zSVQVmj8foMoLauBesLlmyx 1js2aI1xH2KOcg7F+BF5FQCTrz9lwYToJwoyCnHUG5HbDSgI7fHmSpu6N/mWZfmy3jSp wzXxLtgG6NGAH5SJ+nvAAaDIS6YqMRu1JZJV5KFTF47T15gnuV/Lo5hS0hnqEkpffSG0 gByA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WAsGy8Ij; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-159736-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159736-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id d10-20020a1709067f0a00b00a5255b2c343si10296335ejr.339.2024.04.26.01.59.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 01:59:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-159736-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WAsGy8Ij; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-159736-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159736-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 72F8B1F21684 for ; Fri, 26 Apr 2024 08:59:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A23A513D265; Fri, 26 Apr 2024 08:59:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WAsGy8Ij" 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 18A7F23A8 for ; Fri, 26 Apr 2024 08:59:02 +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=1714121943; cv=none; b=n15eLQZpfgLMMbQwhGIbALpRS1nJ7C4n3NNHe8oLCVpcXS6l1iU9nvQmQgaJu5U0003smWzVkHF/Z4y4hbyFOLwv5tADiVYaWEDfbykY/Tcf3cMpYgPakh7iLRHPsNpDJzfb84I8lelM7FcMaNh8vRM2XlDAqLByU3IC0nziouo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714121943; c=relaxed/simple; bh=HMamG9MoqMPfhj+TthBpo7UGGso+zE8qisWfdyo8OB4=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=cgjZjVNO7bg2Gwr9N6jokI1GBCSlXycrGKCfMrJAjhYPTG7qvhurNLHWU1YRlK/8R/HgwESQIh8mwvmtmJ1EAk0eKuRHK+GFmId+JrAlg1hVbmkaBfesp9wb2t4JYci8gULs0X7PrKUCmRPZn9IsOoZp6d6ktyyHxHY8NztB0y0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none 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=WAsGy8Ij; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714121941; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=bRPXKQ+KIC0ZxHv4USsHQnv5JvvbpfCYVb/U1bJ6Y7s=; b=WAsGy8IjOXt5D7jJAyYQhlww+4jl/pVQFbNGI0b0UNmF5M1Svr9/6k6W2KO3hFmABiz8U2 yAXe79VQxwOM7XUYwnplN+3ahgG8/DOgAhl/dKs1hLhjGW0o4zZiN+nJoBfI2mwgY5WHhM ZmPT4SVCAbySYiH7kYTg2sChRYaX2+4= Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-385-xmoWPSJNONCk_w5xjtAhKw-1; Fri, 26 Apr 2024 04:58:59 -0400 X-MC-Unique: xmoWPSJNONCk_w5xjtAhKw-1 Received: by mail-lj1-f200.google.com with SMTP id 38308e7fff4ca-2dc8418e64cso15498491fa.1 for ; Fri, 26 Apr 2024 01:58:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714121937; x=1714726737; h=content-transfer-encoding:in-reply-to:organization:autocrypt :content-language:from:references:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=bRPXKQ+KIC0ZxHv4USsHQnv5JvvbpfCYVb/U1bJ6Y7s=; b=gZFrzAJn79IXqDNujDt+Kf85ij3caw1WKXUZU3BBBmM462MFeaBG2H30Q4DEFJnS+u w6Hug16XNdLSP6Kj59KuwUhfpSjT/AtPv3zni1QYXPe/VE1MDw+8uYEeXk6qeb0foqgC uKp7FmTaehdByGJ+jcWJ4tL2FU87liOBCilf8qEPPc+sfpJ1iSj8cnVTFpMDs8ijc/M9 unIlFl/jv+GSqLNKsPkdrpXwKksSTT+5AEOwmaj9SyC/rmL5QUaXgb03O0RobcsMjtsE TuTU0tu6avkky2WWEA1B33s07+bxbyw8fhBoyAES31bYST3PgF5/IHOcN6QVcXqVC9or 6Rpg== X-Forwarded-Encrypted: i=1; AJvYcCXumUewO5vzxNNNVZjSy3XRs1d3BDccPyKS7yBllNg/pPOaQVAZkuop5WINekT4LftoK0zRRPrrsrLwIFRm3eLKqRlkSUT0AYdhhHln X-Gm-Message-State: AOJu0YyvLoSPiZcdNEp6Eb5ImrLn0/LseSFIN09xXpS1vwq9b3hQW+h3 b/XfRo+FozZxJ7mk5o3Hp4iFN7PpOZVZSLXsxmceoIZULKfhvBMW3MkwaXpnXOVBmS9OTQffoxe cAenpdQ8BVaLWRg1BsfA8+yNO+Oc3U8fPkQLdlmOwuWxS7IjE4ejaiPeg/muDJQ== X-Received: by 2002:a05:651c:14b:b0:2d8:452b:f7af with SMTP id c11-20020a05651c014b00b002d8452bf7afmr1220463ljd.48.1714121937688; Fri, 26 Apr 2024 01:58:57 -0700 (PDT) X-Received: by 2002:a05:651c:14b:b0:2d8:452b:f7af with SMTP id c11-20020a05651c014b00b002d8452bf7afmr1220445ljd.48.1714121937180; Fri, 26 Apr 2024 01:58:57 -0700 (PDT) Received: from ?IPV6:2003:cb:c726:6100:20f2:6848:5b74:ca82? (p200300cbc726610020f268485b74ca82.dip0.t-ipconnect.de. [2003:cb:c726:6100:20f2:6848:5b74:ca82]) by smtp.gmail.com with ESMTPSA id v13-20020a05600c444d00b0041a3f700ccesm18313617wmn.40.2024.04.26.01.58.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 26 Apr 2024 01:58:56 -0700 (PDT) Message-ID: <30d66f75-60c8-4ebf-8451-839806400dd4@redhat.com> Date: Fri, 26 Apr 2024 10:58:56 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/1] hv_balloon: Enable hot-add for memblock sizes > 128 Mbytes To: mhklinux@outlook.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org References: <20240311181238.1241-1-mhklinux@outlook.com> From: David Hildenbrand Content-Language: en-US Autocrypt: addr=david@redhat.com; keydata= xsFNBFXLn5EBEAC+zYvAFJxCBY9Tr1xZgcESmxVNI/0ffzE/ZQOiHJl6mGkmA1R7/uUpiCjJ dBrn+lhhOYjjNefFQou6478faXE6o2AhmebqT4KiQoUQFV4R7y1KMEKoSyy8hQaK1umALTdL QZLQMzNE74ap+GDK0wnacPQFpcG1AE9RMq3aeErY5tujekBS32jfC/7AnH7I0v1v1TbbK3Gp XNeiN4QroO+5qaSr0ID2sz5jtBLRb15RMre27E1ImpaIv2Jw8NJgW0k/D1RyKCwaTsgRdwuK Kx/Y91XuSBdz0uOyU/S8kM1+ag0wvsGlpBVxRR/xw/E8M7TEwuCZQArqqTCmkG6HGcXFT0V9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MaY7UHS341ozXUUI7wC7iKfoUTv03iO9El5f XpNMx/YrIMduZ2+nd9Di7o5+KIwlb2mAB9sTNHdMrXesX8eBL6T9b+MZJk+mZuPxKNVfEQMQ a5SxUEADIPQTPNvBewdeI80yeOCrN+Zzwy/Mrx9EPeu59Y5vSJOx/z6OUImD/GhX7Xvkt3kq Er5KTrJz3++B6SH9pum9PuoE/k+nntJkNMmQpR4MCBaV/J9gIOPGodDKnjdng+mXliF3Ptu6 3oxc2RCyGzTlxyMwuc2U5Q7KtUNTdDe8T0uE+9b8BLMVQDDfJjqY0VVqSUwImzTDLX9S4g/8 kC4HRcclk8hpyhY2jKGluZO0awwTIMgVEzmTyBphDg/Gx7dZU1Xf8HFuE+UZ5UDHDTnwgv7E th6RC9+WrhDNspZ9fJjKWRbveQgUFCpe1sa77LAw+XFrKmBHXp9ZVIe90RMe2tRL06BGiRZr jPrnvUsUUsjRoRNJjKKA/REq+sAnhkNPPZ/NNMjaZ5b8Tovi8C0tmxiCHaQYqj7G2rgnT0kt WNyWQQ== Organization: Red Hat In-Reply-To: <20240311181238.1241-1-mhklinux@outlook.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11.03.24 19:12, mhkelley58@gmail.com wrote: > From: Michael Kelley > > The Hyper-V balloon driver supports hot-add of memory in addition > to ballooning. Current code hot-adds in fixed size chunks of > 128 Mbytes (fixed constant HA_CHUNK in the code). While this works > in Hyper-V VMs with 64 Gbytes or less or memory where the Linux > memblock size is 128 Mbytes, the hot-add fails for larger memblock > sizes because add_memory() expects memory to be added in chunks > that match the memblock size. Messages like the following are > reported when Linux has a 256 Mbyte memblock size: > > [ 312.668859] Block size [0x10000000] unaligned hotplug range: > start 0x310000000, size 0x8000000 > [ 312.668880] hv_balloon: hot_add memory failed error is -22 > [ 312.668984] hv_balloon: Memory hot add failed > > Larger memblock sizes are usually used in VMs with more than > 64 Gbytes of memory, depending on the alignment of the VM's > physical address space. Right, that's the case since 2018. > > Fix this problem by having the Hyper-V balloon driver determine > the Linux memblock size, and process hot-add requests in that > chunk size instead of a fixed 128 Mbytes. Also update the hot-add > alignment requested of the Hyper-V host to match the memblock > size instead of being a fixed 128 Mbytes. That way, we should never be getting unaligned ranges IIRC, correct? I think we added ways in QEMU to guarantee that for the HV-balloon implementation as well. > > The code changes look significant, but in fact are just a Nah, it's okay :) > simple text substitution of a new global variable for the > previous HA_CHUNK constant. No algorithms are changed except > to initialize the new global variable and to calculate the > alignment value to pass to Hyper-V. Testing with memblock > sizes of 256 Mbytes and 2 Gbytes shows correct operation. > > Signed-off-by: Michael Kelley > --- > drivers/hv/hv_balloon.c | 64 ++++++++++++++++++++++++----------------- > 1 file changed, 37 insertions(+), 27 deletions(-) > > diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c > index e000fa3b9f97..d3bfbf3d274a 100644 > --- a/drivers/hv/hv_balloon.c > +++ b/drivers/hv/hv_balloon.c > @@ -425,11 +425,11 @@ struct dm_info_msg { > * The range start_pfn : end_pfn specifies the range > * that the host has asked us to hot add. The range > * start_pfn : ha_end_pfn specifies the range that we have > - * currently hot added. We hot add in multiples of 128M > - * chunks; it is possible that we may not be able to bring > - * online all the pages in the region. The range > + * currently hot added. We hot add in chunks equal to the > + * memory block size; it is possible that we may not be able > + * to bring online all the pages in the region. The range > * covered_start_pfn:covered_end_pfn defines the pages that can > - * be brough online. > + * be brought online. > */ > > struct hv_hotadd_state { > @@ -505,8 +505,9 @@ enum hv_dm_state { > > static __u8 recv_buffer[HV_HYP_PAGE_SIZE]; > static __u8 balloon_up_send_buffer[HV_HYP_PAGE_SIZE]; > +static unsigned long ha_chunk_pgs; Why not stick to PAGES_IN_2M and call this ha_pages_in_chunk? Much easier to get than "pgs". Apart from that looks good. Some helper macros to convert size to chunks etc. might make the code even more readable. -- Cheers, David / dhildenb