Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1200798pxb; Fri, 21 Jan 2022 12:06:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJw8Vgt1e7afFtVuWTZg3Oc+6K4KmHAFaHAJHMiaSgtzy5HLKKqK3OQGCCnRe88ujLXomdBK X-Received: by 2002:a63:115c:: with SMTP id 28mr3975879pgr.382.1642795619177; Fri, 21 Jan 2022 12:06:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642795619; cv=none; d=google.com; s=arc-20160816; b=qg4/8ecaGRKJPc54XCfpjrjUQnLoPdiiko/he7A85RztQ8Iu+iQkF4Xlte59+OhsnA zTzUOtA8tq+/yXpTE2DI9762u+N2Qi6PB9UqF5nzHCRuZ7tMpVaEqaNqAEbBGlDUoF93 ZTr43oPcJeKspgkLkAOMdYlDWx/56JtR9qKR7NGtghXcrqFHZcwYeVPfR4+tSWVwNXJZ MgeCbvhq1DkpJTlBRpssyKYE2ByKymbuFHM1dH3S3tFFKNAByhGXWwnxttCqJlMEd8hJ 7ZzKPeqQ0Vk4KWq4p/xL+TovnFGMu8DG1pVGJCjBd+9KajpKMjKx2M2NhWJwGtQO9OoS GDqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=dB81rBGjzH3Uwh+fac3tDo0v+l951xpXPiqr/ZZyMYo=; b=Wt7jff3jLY9OVhKugtHZ8n1DGVAcoGOBIdqL031Pxmrlvu7ny9RTor2FzZ6UZ3uRhm JWpaTMX5ZbQ0sB+pvtMambXuBCeFs37mCmUW0uqht9WZQHNtUOFQ4XT1XyLqBpeW7YvV 6AAwQjzf6DieNsdnhgzyp3VCTAmSlimPOsIL2RrqGclCVOT10FgnsMs9PBb4DMp4iugA mzuc0+GyFLLOkzPiOha5tgaBvjyheqWO7796wzMHi0HeFV+MD9+Dyxrf2Qm3o1ev21v3 IKe2tN0hpPJrizgHShV2vXyvQ63EWUZwlhNHlX/TJ3dAhk+hxRgh1w0Zch7eL4rOzvMp OuYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="Smx+IJx/"; 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 b4si6593206plr.18.2022.01.21.12.06.47; Fri, 21 Jan 2022 12:06:59 -0800 (PST) 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=20210112 header.b="Smx+IJx/"; 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 S238485AbiASWc7 (ORCPT + 99 others); Wed, 19 Jan 2022 17:32:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230088AbiASWc6 (ORCPT ); Wed, 19 Jan 2022 17:32:58 -0500 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C3F8C061574; Wed, 19 Jan 2022 14:32:58 -0800 (PST) Received: by mail-ed1-x52b.google.com with SMTP id z22so19945112edd.12; Wed, 19 Jan 2022 14:32:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=dB81rBGjzH3Uwh+fac3tDo0v+l951xpXPiqr/ZZyMYo=; b=Smx+IJx/hidTWiy5wBwlWwGdHCV8qlTH0yM6NbaW0ypD5s27vLNbHqdIsWjnubchGa YjhosjQxnr3hAZwLzelMtgSZUok5zYUzQc4KxK6zZD4vBn5BhTvfd3jtT71c0h5Nky4H +Um3eVzJ/ltkeu8AMMMaPZ1geQZ7vjxQaFmD2+G7739FxjSf9PFGplx+UO6HfCb9uasE eaemxPsz3HzHhZpjAHtEDp81QFqmHfsohfC0BPGqT2aHhovAaUwYWpg+hj2VvWMYnZKf 9ETEmzdXNLFmB9cCFi1MEe/Rd3/pXKMF8gb4almDJruoV1NYXvOqzla83lzNURwbWnPx buEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=dB81rBGjzH3Uwh+fac3tDo0v+l951xpXPiqr/ZZyMYo=; b=0HRw3EusFEGE7RtJFs4Klz3/Djl6U1GomcmKGcq9ep+gtp+nIh0EX8JZN8xFQLR/Sm G2yxmxp8WlbGx16XIMSDWYn9DQH1KH0x93QXikPn4sLRJlJB02229jRT/7tH1Kq6ADWY CouCdwVtwEf4VhQTDxjx94BWfX5c/3UZ7hMTNi2zOMj+q6709yi6EXXMJDI9m077EmLw 9zAYj1iqffmN9nAkGfDWgIuu36x5+0d16wd05p9vkn1o23yYUiEp5+AMneI7bc6rkrE+ KmYV9eLZpDPG9c/xIEEszPzJydOIvC2bO6VjLwHlO4CLRZI65Lrs8FfY3jrfG49whwaV gz3Q== X-Gm-Message-State: AOAM532igfwJGCrOaOuyFRJVFrYlA6P4HMJv4Fio2A6uXP7Rew7MgSeT C3cUzS12593+j6F4MdsCdqEjhDpDv+JDIw== X-Received: by 2002:a17:907:75dc:: with SMTP id jl28mr26334674ejc.13.1642631576308; Wed, 19 Jan 2022 14:32:56 -0800 (PST) Received: from anparri (host-79-37-66-48.retail.telecomitalia.it. [79.37.66.48]) by smtp.gmail.com with ESMTPSA id n5sm311492ejg.21.2022.01.19.14.32.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jan 2022 14:32:55 -0800 (PST) Date: Wed, 19 Jan 2022 23:32:46 +0100 From: Andrea Parri To: Yanming Liu Cc: linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, Andres Beltran , Dexuan Cui , Wei Liu , Stephen Hemminger , Haiyang Zhang , "K. Y. Srinivasan" , Michael Kelley Subject: Re: [PATCH] Drivers: hv: balloon: account for vmbus packet header in max_pkt_size Message-ID: <20220119223246.GA1539@anparri> References: <20220119202052.3006981-1-yanminglr@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220119202052.3006981-1-yanminglr@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 20, 2022 at 04:20:52AM +0800, Yanming Liu wrote: > Commit adae1e931acd ("Drivers: hv: vmbus: Copy packets sent by Hyper-V > out of the ring buffer") introduced a notion of maximum packet size in > vmbus channel and used that size to initialize a buffer holding all > incoming packet along with their vmbus packet header. hv_balloon uses > the default maximum packet size VMBUS_DEFAULT_MAX_PKT_SIZE which matches > its maximum message size, however vmbus_open expects this size to also > include vmbus packet header. This leads to 4096 bytes > dm_unballoon_request messages being truncated to 4080 bytes. When the > driver tries to read next packet it starts from a wrong read_index, > receives garbage and prints a lot of "Unhandled message: type: > " in dmesg. > > Allocate the buffer with HV_HYP_PAGE_SIZE more bytes to make room for > the header. > > Fixes: adae1e931acd ("Drivers: hv: vmbus: Copy packets sent by Hyper-V out of the ring buffer") > Suggested-by: Michael Kelley (LINUX) > Suggested-by: Andrea Parri (Microsoft) > Signed-off-by: Yanming Liu > --- > The patch was "[PATCH v2] hv: account for packet descriptor in maximum > packet size". As pointed out by Michael Kelley [1], other hv drivers > already overallocate a lot, and hv_balloon is hopefully the only > remaining affected driver. It's better to just fix hv_balloon. Patch > summary is changed to reflect this new (much smaller) scope. hopefully - adeguately describing what/how we "know" (here), it remarks us that our estimates are empirical (and that people may have different opinions about "safe" estimates ;-)) Reviewed-by: Andrea Parri (Microsoft) Thanks, Andrea > [1] https://lore.kernel.org/linux-hyperv/CY4PR21MB1586D30C6CEC81EFC37A9848D7599@CY4PR21MB1586.namprd21.prod.outlook.com/ > > drivers/hv/hv_balloon.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c > index ca873a3b98db..f2d05bff4245 100644 > --- a/drivers/hv/hv_balloon.c > +++ b/drivers/hv/hv_balloon.c > @@ -1660,6 +1660,13 @@ static int balloon_connect_vsp(struct hv_device *dev) > unsigned long t; > int ret; > > + /* > + * max_pkt_size should be large enough for one vmbus packet header plus > + * our receive buffer size. Hyper-V sends messages up to > + * HV_HYP_PAGE_SIZE bytes long on balloon channel. > + */ > + dev->channel->max_pkt_size = HV_HYP_PAGE_SIZE * 2; > + > ret = vmbus_open(dev->channel, dm_ring_size, dm_ring_size, NULL, 0, > balloon_onchannelcallback, dev); > if (ret) > -- > 2.34.1 >