Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5604548ybp; Tue, 8 Oct 2019 05:42:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqy0lF/K2FcDULtfjmsZFkcBWXK7Gsf2k7JMrto1qr0J30zt+tIVbKUsum+dH7prBJFuIokj X-Received: by 2002:a50:f00c:: with SMTP id r12mr34078068edl.274.1570538536488; Tue, 08 Oct 2019 05:42:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570538536; cv=none; d=google.com; s=arc-20160816; b=A5+OpF1UL+1Wync2DW2B8HDN97e4h8eb5H8tvTAz71sRaANi6cINZEOyclsyUwGrSZ 4/c3H4L9zUoc8LMT1QreS7rIKnscWzODLgO1E2OhMdK1REIUjvTjhcc2zLcraKHYdmnz lXZxNQx5HysvmmJz+Ujh1rx9lJJ14ZvgabS7yRdqvjhWNQYtbMaJYRgH4CFmxihGIjeZ v140+vREZQeu3HiagT9AJLMnidlQvakxdzhvcYG5Rt87MHeHOjbDIrH2Ea8tC9XdKusV xZtQkcaxgGXN8rJsMhP0MMkcyPj/OX+fiQGy6St3HzJA3j5y8fl9TyOkkZDFHDalelD/ Ureg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=IX48zcw0hHbQ+qkGCrH/k9CNB0tesSY9qolmQpCaa38=; b=nu0SjiUnl0bY5VcMbiNBmY88EiTMS2vNA/8/DKjJZrbG6ifZLpoDdmCmNt6gmRzBL9 e5m4mnRXPtuDtgwXFMIgXJOZqEqddbmBSR70uedgSUkpYFtRmF4swm6Vh5HU9pJLPi8Y Smh6sMVWHylH6WF+eicFAucDwKQEAheNTy7dmYHoXCCPXCCeaxwkY/3OyC3wDDu5PKOA HJbkRdisj+itywfXamQ8HN5QT2yFjdskQ/0FWwUJTOUbPtc8AM8RXXEMuGY8M2smnXK2 c4jQBPcz7NMyIUqlrkkMb0iyHqsIIYQHhGm4Rd/3fGI2v/YRfAgK63V8KZY85lSQnm0L PCyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="kQ/feqhK"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id s42si10123089edm.292.2019.10.08.05.41.52; Tue, 08 Oct 2019 05:42:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="kQ/feqhK"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1730764AbfJHMle (ORCPT + 99 others); Tue, 8 Oct 2019 08:41:34 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:39012 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730332AbfJHMle (ORCPT ); Tue, 8 Oct 2019 08:41:34 -0400 Received: by mail-wm1-f67.google.com with SMTP id v17so2959586wml.4; Tue, 08 Oct 2019 05:41:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=IX48zcw0hHbQ+qkGCrH/k9CNB0tesSY9qolmQpCaa38=; b=kQ/feqhKZqOhEiMl9EqpWN3ZBcmBBS5KZKhjLd9WrsivqVclKascK3kYXKIcsU/cYL 7Gr+h/pY5FRQXLcOFyUbeg9WMQLwIEZanYZ227fQQx/JFTBYaOzVpdxcyo3SLV2uy+hi T791PwKBRrGoMF1VptlWAewkQTpfTptEFFfAGDsxxVnOHKy61jmHWPFRvs3300cfbtWq cw5MDItifsTCnX3ZUX7A/j0ejrabrl/dmCtLqY/jo+BSTHGafV+cQPXgSio9hUtyHkyp N6C0iaDbsawugInLQwA5GBAeXN39KKB1n3wk7HHZFkL0fxYivwomcTRtG3UMv2unDDji VYYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=IX48zcw0hHbQ+qkGCrH/k9CNB0tesSY9qolmQpCaa38=; b=NaZgC7Kxj95ACBZRkTZymKUvVWlUcaIqkx4AJxJ41F4O6uy8dmSt8vL8Za83u+KX/b KrgV2iySqcHJ+3dLOKk/PUfwtEPxy6AUZ+nddsQSlYhOq1ouzmkB2n+6RhCB4qMzN7Vg F6shmPz0FZX8ZqFnPwYKNwqqo78E33hlfH0I5dJP8HQt3RgC9O4RVL3+bEefVIw04W3w 1WnRv8Sb1NO+a8HkJ4pL1Ys+wbDJ3Sah50tsOtcrYoqIM4X102O3NN1auS9ODFpXoHxC wn2vFe8LHmYuQrCitZKLH/F1Vq8iUT+Goegq/ckIz7iQF0kkO+so7PzBKE/qavA/iAH0 kA7Q== X-Gm-Message-State: APjAAAXDa6MysbBcFd22/n0OtmCrBxAyJqY5N38oPfGCN5EuTkEYp+v0 gobJjrH0sIDSwW56cn67ssk= X-Received: by 2002:a7b:cd95:: with SMTP id y21mr3732775wmj.53.1570538491517; Tue, 08 Oct 2019 05:41:31 -0700 (PDT) Received: from andrea.guest.corp.microsoft.com ([2a01:110:8012:1012:c582:959a:923b:9ec]) by smtp.gmail.com with ESMTPSA id w5sm19765471wrs.34.2019.10.08.05.41.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2019 05:41:30 -0700 (PDT) Date: Tue, 8 Oct 2019 14:41:24 +0200 From: Andrea Parri To: Vitaly Kuznetsov Cc: linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, "K . Y . Srinivasan" , Haiyang Zhang , Stephen Hemminger , Sasha Levin , Michael Kelley , Dexuan Cui Subject: Re: [PATCH 1/2] Drivers: hv: vmbus: Introduce table of VMBus protocol versions Message-ID: <20191008124052.GA11245@andrea.guest.corp.microsoft.com> References: <20191007163115.26197-1-parri.andrea@gmail.com> <20191007163115.26197-2-parri.andrea@gmail.com> <87eezo1nrr.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87eezo1nrr.fsf@vitty.brq.redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > @@ -244,21 +234,18 @@ int vmbus_connect(void) > > * version. > > */ > > > > - version = VERSION_CURRENT; > > + for (i = 0; ; i++) { > > + version = vmbus_versions[i]; > > + if (version == VERSION_INVAL) > > + goto cleanup; > > If you use e.g. ARRAY_SIZE() you can get rid of VERSION_INVAL - and make > this code look more natural. Thank you for pointing this out, Vitaly. IIUC, you're suggesting that I do: for (i = 0; i < ARRAY_SIZE(vmbus_versions); i++) { version = vmbus_versions[i]; ret = vmbus_negotiate_version(msginfo, version); if (ret == -ETIMEDOUT) goto cleanup; if (vmbus_connection.conn_state == CONNECTED) break; } if (vmbus_connection.conn_state != CONNECTED) break; and that I remove VERSION_INVAL from vmbus_versions, yes? Looking at the uses of VERSION_INVAL, I find one remaining occurrence of this macro in vmbus_bus_resume(), which does: if (vmbus_proto_version == VERSION_INVAL || vmbus_proto_version == 0) { ... } TBH I'm looking at vmbus_bus_resume() and vmbus_bus_suspend() for the first time and I'm not sure about how to change such check yet... any suggestions? Mmh, I see that vmbus_bus_resume() and vmbus_bus_suspend() can access vmbus_connection.conn_state: can such accesses race with a concurrent vmbus_connect()? Thanks, Andrea > > > > - do { > > ret = vmbus_negotiate_version(msginfo, version); > > if (ret == -ETIMEDOUT) > > goto cleanup; > > > > if (vmbus_connection.conn_state == CONNECTED) > > break; > > - > > - version = vmbus_get_next_version(version); > > - } while (version != VERSION_INVAL); > > - > > - if (version == VERSION_INVAL) > > - goto cleanup; > > + } > > > > vmbus_proto_version = version; > > pr_info("Vmbus version:%d.%d\n",