Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2396182ybb; Mon, 30 Mar 2020 05:25:06 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtf6OuCKGW+3XxLQy0Y1GMo5jGDh6BceyxY7yXlkprJftPcGjkHw69ipvGKIQxKC8lyd+rP X-Received: by 2002:a9d:bf5:: with SMTP id 108mr9370453oth.260.1585571106402; Mon, 30 Mar 2020 05:25:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585571106; cv=none; d=google.com; s=arc-20160816; b=R1p/JDmDvJpVgGL78Q2PbkP9sij/LJUBSYvxJ7QKsKPxATOgPRijziZQK74ENf0+cb LMqSJVCQ84JrjzCogSLqX05gPRWWZFmeVlGznR965rYye4ghG0wC0HogwYO0EjzfAwjn x5muZaUP/BQhfsTQ4PR5B5oYxYeiskVtGr+TEmQCKSgOLLCVXitaWRiRwkaij6n85QtZ 3Xkv4pDEPTrqcV18GbEVcjvppJE0Qu8+l1zljWamLQQFlRHsZkgvR45Mo/MbRw+eGr4T rEY6uucqiZBJBtQwzXBeaY0qGNqF9Me7FkkayLznT7xfyemCl+SCuyIGJ9Y1UJaMIKUn tltg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=/ygALAJVOjqUJKfasvnnjImKIeALHsYUPdnk+AuUynM=; b=dukCJpuccS7wPx7DIBSrFBUO2T9otecYs5W5YzljeIUQf63nzK3tDj2LzONj7OehX2 23CeaFli7DL3TfXWvedviKaiKXY0N52X5gJRFu/IsLOZCoc4r0ZW9crMOaP0mzJLwzxL ub75JNd2Xhkm+JLybdPpahLj194PvkJZ+mFQJaWibma0V232/byVB6wugECa3q09aoAq eFdiGYBfM2In57nljz7F7yUogqSjZ/tsRz9cIZG6ZlK2kxTwIAlL3S3aDRgycGo+6JUR L28Q0zL8bXgC1wlJU1a+KdgPwOv0yCDLqWVP+971XWKcj+EWuM/B3C3MbGuqRj4suOUN d98A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IkzJhIHR; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e24si6184722otq.2.2020.03.30.05.24.51; Mon, 30 Mar 2020 05:25:06 -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=@redhat.com header.s=mimecast20190719 header.b=IkzJhIHR; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730053AbgC3MYX (ORCPT + 99 others); Mon, 30 Mar 2020 08:24:23 -0400 Received: from us-smtp-delivery-74.mimecast.com ([216.205.24.74]:40558 "EHLO us-smtp-delivery-74.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729966AbgC3MYX (ORCPT ); Mon, 30 Mar 2020 08:24:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585571061; 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=/ygALAJVOjqUJKfasvnnjImKIeALHsYUPdnk+AuUynM=; b=IkzJhIHRIyM6gElBVfZ8Tj5lSWRZsj1W6NdsiOxVKl1GQq6esEarejIORyEFGdWd7XDrQZ REeH52zPRJMpaTiw2FMiKHJVWCC+l4u4lV/VBFfIiQnxbVUBAXbEOVaX6jSGODk3zXUKiD yfoG+pDPHbLzSPQ/H6/87hpz+K6gfO8= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-295--IW9Of8MMzerEcPZ0O7SpQ-1; Mon, 30 Mar 2020 08:24:20 -0400 X-MC-Unique: -IW9Of8MMzerEcPZ0O7SpQ-1 Received: by mail-wr1-f69.google.com with SMTP id d1so11158344wru.15 for ; Mon, 30 Mar 2020 05:24:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=/ygALAJVOjqUJKfasvnnjImKIeALHsYUPdnk+AuUynM=; b=XQ+JKMVRHFCIdDD4hpC93c7Krv7wcj+e4IURA6fJLrE71xt5A5QMSZe3SlW79UW1Ox /AX5//9sDL9bHA38CXKb+mn5odPcwXhpwlEGUoOtkRy+XRqEehlnr54mkJs2xHP6pLsb 6muqk/T+ghH8AuKKn8lT/35qrB8OynRKe1t3tNdtvmK0WSHkIHkzDcaG153oQe2GIf6a 7CkssjPLUIKFhpqAWe6oL2gexwH6HWCtGKhk0gyrYN00iuXk8BKyjAPwqJizMMoyNkN3 eRR5IZqceTWOlz4Pcsx+dbNg+tm9W3MBng86ZSezLuZ8pqzwjg5jOSTxdDRsFut8LDb5 voiw== X-Gm-Message-State: ANhLgQ2fVnQZbaM/8o+itFTvxKLm4UPae3iYRHczo8sUw7GgzkGKijJU BuE0HDY7itltMo8/sDbOccNHYk7ntaIlQXJmPEB7+B8jEZp5dLpXpqDD/oM2UvOZz70Ii7DXCTa hNG/qj0dg8EfvuEd4WvpgOmRV X-Received: by 2002:adf:ec02:: with SMTP id x2mr14564034wrn.365.1585571058691; Mon, 30 Mar 2020 05:24:18 -0700 (PDT) X-Received: by 2002:adf:ec02:: with SMTP id x2mr14564012wrn.365.1585571058374; Mon, 30 Mar 2020 05:24:18 -0700 (PDT) Received: from vitty.brq.redhat.com (g-server-2.ign.cz. [91.219.240.2]) by smtp.gmail.com with ESMTPSA id 9sm20168122wmm.6.2020.03.30.05.24.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Mar 2020 05:24:17 -0700 (PDT) From: Vitaly Kuznetsov To: Michael Kelley , Andrea Parri Cc: Dexuan Cui , KY Srinivasan , Haiyang Zhang , Stephen Hemminger , Wei Liu , "linux-hyperv\@vger.kernel.org" , Boqun Feng , "linux-kernel\@vger.kernel.org" Subject: RE: [RFC PATCH 02/11] Drivers: hv: vmbus: Don't bind the offer&rescind works to a specific CPU In-Reply-To: References: <20200325225505.23998-1-parri.andrea@gmail.com> <20200325225505.23998-3-parri.andrea@gmail.com> <871rpf5hhm.fsf@vitty.brq.redhat.com> <20200326154710.GA13711@andrea> <87sghv3u4a.fsf@vitty.brq.redhat.com> <20200328170833.GA10153@andrea> Date: Mon, 30 Mar 2020 14:24:16 +0200 Message-ID: <87o8se2fpr.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Michael Kelley writes: > From: Andrea Parri Sent: Saturday, March 28, 2020 10:09 AM >> >> > In case we believe that OFFER -> RESCINF sequence is always ordered >> > by the host AND we don't care about other offers in the queue the >> > suggested locking is OK: we're guaranteed to process RESCIND after we >> > finished processing OFFER for the same channel. However, waiting for >> > 'offer_in_progress == 0' looks fishy so I'd suggest we at least add a >> > comment explaining that the wait is only needed to serialize us with >> > possible OFFER for the same channel - and nothing else. I'd personally >> > still slightly prefer the algorythm I suggested as it guarantees we take >> > channel_mutex with offer_in_progress == 0 -- even if there are no issues >> > we can think of today (not strongly though). >> >> Does it? offer_in_progress is incremented without channel_mutex... >> No, it does not, you're right, by itself the change is insufficient. >> IAC, I have no objections to apply the changes you suggested. To avoid >> misunderstandings: vmbus_bus_suspend() presents a similar usage... Are >> you suggesting that I apply similar changes there? >> >> Alternatively: FWIW, the comment in vmbus_onoffer_rescind() does refer >> to "The offer msg and the corresponding rescind msg...". I am all ears >> if you have any concrete suggestions to improve these comments. >> > > Given that waiting for 'offer_in_progress == 0' is the current code, I think > there's an argument to made for not changing it if the change isn't strictly > necessary. This patch set introduces enough change that *is* necessary. :-) > Sure. I was thinking a bit more about this and it seems that over years we've made the synchronization of channels code too complex (every time for a good reason but still). Now (before this series) we have at least: vmbus_connection.channel_mutex vmbus_connection.offer_in_progress channel.probe_done channel.rescind Workqueues (vmbus_connection.work_queue, queue_work_on(vmbus_connection.connect_cpu),...) channel.lock spinlock (the least of the problems) Maybe there's room for improvement? Out of top of my head I'd suggest a state machine for each channel (e.g something like OFFERED->OPENING->OPEN->RESCIND_REQ->RESCINDED->CLOSED) + refcounting (subchannels, open/rescind/... requests in progress, ...) + non-blocking request handling like "Can we handle this rescind offer now? No, refcount is too big. OK, rescheduling the work". Maybe not the best design ever and I'd gladly support any other which improves the readability of the code and makes all state changes and synchronization between them more obvious. Note, VMBus channel handling driven my messages (unlike events for ring buffer) is not performance critical, we just need to ensure completeness (all requests are handled correctly) with forward progress guarantees (no deadlocks). I understand the absence of 'hot' issues in the current code is what can make the virtue of redesign questionable and sorry for hijacking the series which doesn't seem to make things worse :-) -- Vitaly