Received: by 2002:a19:f614:0:0:0:0:0 with SMTP id x20csp23325lfe; Fri, 15 Apr 2022 17:38:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTDYtFkD1u887aL0nWyqnYWOYgKfQwLxw/+dYbUkFSsaRF6/71CulXpzlaj0KA1g+X8W0U X-Received: by 2002:a63:54c:0:b0:39d:a5ab:d797 with SMTP id 73-20020a63054c000000b0039da5abd797mr1199021pgf.102.1650069539173; Fri, 15 Apr 2022 17:38:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650069539; cv=none; d=google.com; s=arc-20160816; b=nAy/wewocW/xZLvXm5+qkPaJBiucGXczl+8yyaCRZ4UtwDEVWVatz4JzCPgLlM+ybg ByczZWqs2fKp5kr3wOrfgMl674rRDlYTNcA7FalgxFVxNuolJPKmQ1j+6wDUT9MwMwfA 4JMyBxTqe0l/B3yx5UmucB9vcLjU0eQA5J94WLlcUVCRyLLj5yqSnO+oKtFNJ3iQ9MsS C5UgeJ1m5YOt0wfpdpKVDvyjhbgDvFEFbIn3ZPA6PI0kr4aNOHwiTtmideAx8Ps+ZJR8 u14uCi3U+Gp2+HoZDOfIPpkrzBGkfehiBchrypDFUT1NNPkesg9kRZ96Oeqd5cAaXwww CLOA== 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=tPz8jhLel5NCB/c+wgUxB3HxNS9jpiNK/WGqp6Lz5oE=; b=F9KItGBF6qAH8h2JvYqTIzmmtn3rBZQoX/8zkmIvJEaGWPZ6+bkcnA9Np3bgY3sPf3 J6qkCVcBDbewFYJ1gvobrdb6L0KMcPCDqyzjBMi4uYgYoCoGdLcT88K6V6EWnmB84O16 Ouxcc68O4Na/TyFOiJWBfe0zA8gBNR8eLIIMcR6wFjr93Dih4xKku/OL0Wd4R8OFi69k ZeY0ecDDDkNYT18/AC0qrvYjfn0mzWJLpYG3rWvvobgoQ2zrCNRfWJJh9FWTb3uhtH+F z7a630ihAiUGhyYfu4WWTFOLesqTk4i4hgyU098zBX2SiUAjnrWyquPufrGf72gMpi1B cz6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=bmzvRoxX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id e123-20020a636981000000b003816043efe0si2740201pgc.469.2022.04.15.17.38.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 17:38:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=bmzvRoxX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D7A5BF55C7; Fri, 15 Apr 2022 17:33:56 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244779AbiDORI2 (ORCPT + 99 others); Fri, 15 Apr 2022 13:08:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356101AbiDORIB (ORCPT ); Fri, 15 Apr 2022 13:08:01 -0400 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 9CF4A84EFD; Fri, 15 Apr 2022 10:05:32 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id g20so10524400edw.6; Fri, 15 Apr 2022 10:05:32 -0700 (PDT) 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=tPz8jhLel5NCB/c+wgUxB3HxNS9jpiNK/WGqp6Lz5oE=; b=bmzvRoxXUYN08ImLI8GChiltnBZ++UpOwMCJABu0q9+yZCFc6P3KmJ+eCUxf3GUNTz JmCY41h0LXy/oh3PT2JmAfv+662KfBG6RdJqoAA59mbedZm/Bw/zjBJvPOs8drW6CfXh 8hGFU2cKLx9xQlfYDUlA98Huv0jMJTUicz33uiImtlh3l31R1KL1TC9/W1gbhw4+GXCl WLBQzr69B3R3z2gz2UtPVSWgIr3g6auVvg7E9jAXa5vG3Bm8wUjgXWr6LMT9epg91v4d 8UmzLTu0bcUX0GQS6oOKvRmauc4kFRpClp3vivZyMZIWnmaFdU7K+B9Fn9PbR1ny/lVx e0PQ== 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=tPz8jhLel5NCB/c+wgUxB3HxNS9jpiNK/WGqp6Lz5oE=; b=nXLXG9fpHM347tttGn+gbdC+D5tKOGRfWryt0BsUCzCveNBA0H88OgxDdHqVHvTSje vMVJRn3an/JJfSUtUwigV6R2yvNGvbk6zORqI3Ukvul0Q+aOwGDBruZr1eD6BqFFXa1l /c6zVkD4u5bDUzAHtR7HrLjyQ5R0dtDlxpItmGFqULoJktFaD928STlerivVdSyzR36K xr+7rhdzfndwfBKXFo3TR3QSTcCJEEjZVd9a5V+7hOkfipwNbS3hmYCd+4Tn2tFphV61 RpOtR4irR944Ew3pDwEr3Pfha3/XyIuI/4tcx/IShKEDePsFfNmDVvt5WZKsHNXvzzgf WpcA== X-Gm-Message-State: AOAM533HztuxpYNl1pCtIrmkVUu6RbI0Zi2KOxu35r4irJ98HPYHeVBS K/kR3kfY6Lke4O6XTKAz1KE= X-Received: by 2002:a05:6402:14b:b0:418:d06e:5d38 with SMTP id s11-20020a056402014b00b00418d06e5d38mr211943edu.90.1650042331209; Fri, 15 Apr 2022 10:05:31 -0700 (PDT) Received: from anparri (host-79-52-64-69.retail.telecomitalia.it. [79.52.64.69]) by smtp.gmail.com with ESMTPSA id ee17-20020a056402291100b0041fe1e4e342sm2842777edb.27.2022.04.15.10.05.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 10:05:30 -0700 (PDT) Date: Fri, 15 Apr 2022 19:05:23 +0200 From: Andrea Parri To: "Michael Kelley (LINUX)" Cc: KY Srinivasan , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , Stefano Garzarella , David Miller , Jakub Kicinski , Paolo Abeni , "linux-hyperv@vger.kernel.org" , "virtualization@lists.linux-foundation.org" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [RFC PATCH 6/6] Drivers: hv: vmbus: Refactor the ring-buffer iterator functions Message-ID: <20220415170523.GB97823@anparri> References: <20220413204742.5539-1-parri.andrea@gmail.com> <20220413204742.5539-7-parri.andrea@gmail.com> <20220415070031.GE2961@anparri> <20220415162811.GA47513@anparri> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 15, 2022 at 04:44:50PM +0000, Michael Kelley (LINUX) wrote: > From: Andrea Parri Sent: Friday, April 15, 2022 9:28 AM > > > > On Fri, Apr 15, 2022 at 09:00:31AM +0200, Andrea Parri wrote: > > > > > @@ -470,7 +471,6 @@ struct vmpacket_descriptor *hv_pkt_iter_first_raw(struct > > > > > vmbus_channel *channel) > > > > > > > > > > return (struct vmpacket_descriptor *)(hv_get_ring_buffer(rbi) + rbi- > > > > > >priv_read_index); > > > > > } > > > > > -EXPORT_SYMBOL_GPL(hv_pkt_iter_first_raw); > > > > > > > > Does hv_pkt_iter_first_raw() need to be retained at all as a > > > > separate function? I think after these changes, the only caller > > > > is hv_pkt_iter_first(), in which case the code could just go > > > > inline in hv_pkt_iter_first(). Doing that combining would > > > > also allow the elimination of the duplicate call to > > > > hv_pkt_iter_avail(). > > > > Back to this, can you clarify what you mean by "the elimination of..."? > > After moving the function "inline", hv_pkt_iter_avail() would be called > > in to check for a non-NULL descriptor (in the inline function) and later > > in the computation of bytes_avail. > > I was thinking something like this: > > bytes_avail = hv_pkt_iter_avail(rbi); > if (bytes_avail < sizeof(struct vmpacket_descriptor)) > return NULL; > bytes_avail = min(rbi->pkt_buffer_size, bytes_avail); > > desc = (struct vmpacket_descriptor *)(hv_get_ring_buffer(rbi) + rbi->priv_read_index); Thanks for the clarification, I've applied it. Andrea > And for that matter, hv_pkt_iter_avail() is now only called in one place. > It's a judgment call whether to keep it as a separate helper function vs. > inlining it in hv_pkt_iter_first() as well. I'm OK either way. > > > Michael > >