Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp631780ybt; Wed, 17 Jun 2020 09:50:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpyETfDG7GXYCjVcfRo2uwl5QR7ew54H6wMOmN0SwwgWNWnWc/jAXdGlG8dL73x0SK60Vb X-Received: by 2002:a17:906:f155:: with SMTP id gw21mr77899ejb.388.1592412634940; Wed, 17 Jun 2020 09:50:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592412634; cv=none; d=google.com; s=arc-20160816; b=pjUedQSau56gLoKBy9TJjASk2u/IUeAZ7U5Dl6PPOM6NDf0LvOMoOaHm7VeiRwP05+ FGVh0Yfke3tnLiuQYq4rt45wNaq9BWPZLsqkqs7z3bnu5e/Xtu7nOOiITb4Ld7eKxRo/ nWlVAYF8ZtZYv6SVAyKkH6YDnV3ZXe7p3u1kegcbcq5br9hbm5a4vvx3jBhWMM7Q6d6s Xr6JktZuPOa1IB25TjA5zKDGH5YAEWf5ch2myhOET1ufushYaZF53m39SX0/sVGOdbJL 9CD7K33+uEjCeH9p5GC0Z+M03aINM9KdO0/TlzRvkcGu2940UtmfSO2vHcytbmmvoQMe Aofw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KgaamQcsTSd9AMXog0Hi7EO7KOr3psID2I79QRDOuPQ=; b=XD/YNWpWcovF2rOuv4OPqlgadTl2nnSc4L0CvM8NuYUCzYi0uhWnpapA4S+v5SiOOJ ptRNLJGoqVbidV9JNfYSEoiO7J9FNGX3pZLa2Vw822Yq6siDXjAKW1Dep5gxkGkmqi+Q 5JYpCRmJeidm6q7jMMyLQX7Gd3f/T3u09KP93uZ5TG9aSch+yIlP7HHM273JuZKBtI7L O5tRz3HRmXxEIn6fyOBQUtAo4bn0RQv1eB3XbH6wz8zEUO9+FeqlG/VcUJ3uJOmNzPG8 ZTmFEcQZUci6PKvV6Vj5ldCOZU+NGhwf61ep0buMoMOdyobKdMmFV1JzGppQTFTLscbJ MU6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=baZKsS2P; 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 z20si272898eja.58.2020.06.17.09.50.12; Wed, 17 Jun 2020 09:50:34 -0700 (PDT) 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=20161025 header.b=baZKsS2P; 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 S1727043AbgFQQsM (ORCPT + 99 others); Wed, 17 Jun 2020 12:48:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727015AbgFQQsC (ORCPT ); Wed, 17 Jun 2020 12:48:02 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3C6EC06174E; Wed, 17 Jun 2020 09:48:00 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id x6so3049567wrm.13; Wed, 17 Jun 2020 09:48:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KgaamQcsTSd9AMXog0Hi7EO7KOr3psID2I79QRDOuPQ=; b=baZKsS2PSQFJV4FGXbBDHaDDNGu50Q0QQj8+IWh1E0Wk3M37gdiUZ1KQ0Gz9vNQFCy gjFGqdPgcyytw3YSKzxtsntZuKvSLDLaTwtxcGyx++7wuyIQmFHzYgMczfwhjpDJWxOk yYqlzDhuBhg71YuNc37f6+LRYJbVnAQxeHe2fKlT06IKvE9UnTBAmoZ5YyQYgf+qbjKn 9Mb8Ilyob2jkz/mHGNMqkv1+6CU3QA/2dxp5pRhLcfE7N64r9h6bwz0N9bTP6cK5UZrb zC47QMsh5cDX66rQfWW7XYe6BbA7CSiqVmYuB6YQoUGXK7KNmBYKCcRC6Zfa99tHmJeu 5UvQ== 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:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KgaamQcsTSd9AMXog0Hi7EO7KOr3psID2I79QRDOuPQ=; b=R7aobpB+WEf66okJ37ZmBaTrk/Mv0y35JC2jws7SYDM/GqE/JTyMYelxfI/Zx8oFtz 0G0oNzaR2/MPi6PnTSk7/l0iezx96SVKB0B/SjKOeVB9wNnu7Q3HQDVHHX4niHKKv3LN liUDw/W4v6wRv6NQfS/GZOpNeYCoQxm9t4sEDPgOQtWXeAPVMmLZYJZTpIo1rwpqpsod naDVFJG5480OmCjSH5Fs18qtDtvaRSz82IzVRGG2ueYGNATOxEtrvvxTYjgaMjy0RsM3 +eJWP16takoJLvY2pNUr0lMlf/h2gfbrQbGzsmUIBgAP2CRq/pz6Osqd2BiloDXI3/LN VAng== X-Gm-Message-State: AOAM532fKpgn+x2arEfN+ISvyQzPAg/3f3LVpY2RSpLXwetvAKgmFsAR UNJQRBMFumnizHGLCEUvUCjHV3X0WWptYg== X-Received: by 2002:a5d:500d:: with SMTP id e13mr189466wrt.150.1592412479190; Wed, 17 Jun 2020 09:47:59 -0700 (PDT) Received: from localhost.localdomain (ip-213-220-210-175.net.upcbroadband.cz. [213.220.210.175]) by smtp.gmail.com with ESMTPSA id g3sm199165wrb.46.2020.06.17.09.47.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2020 09:47:58 -0700 (PDT) From: "Andrea Parri (Microsoft)" To: "K . Y . Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Michael Kelley Cc: linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, "Andrea Parri (Microsoft)" Subject: [PATCH 5/8] Drivers: hv: vmbus: Use channel_mutex in channel_vp_mapping_show() Date: Wed, 17 Jun 2020 18:46:39 +0200 Message-Id: <20200617164642.37393-6-parri.andrea@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200617164642.37393-1-parri.andrea@gmail.com> References: <20200617164642.37393-1-parri.andrea@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The primitive currently uses channel->lock to protect the loop over sc_list w.r.t. list additions/deletions but it doesn't protect the target_cpu(s) loads w.r.t. a concurrent target_cpu_store(): while the data races on target_cpu are hardly of any concern here, replace the channel->lock critical section with a channel_mutex critical section and extend the latter to include the loads of target_cpu; this same pattern is also used in hv_synic_cleanup(). Signed-off-by: Andrea Parri (Microsoft) --- drivers/hv/vmbus_drv.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index b5ae45eb8aef7..9e39692dc13ee 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -507,18 +507,17 @@ static ssize_t channel_vp_mapping_show(struct device *dev, { struct hv_device *hv_dev = device_to_hv_device(dev); struct vmbus_channel *channel = hv_dev->channel, *cur_sc; - unsigned long flags; int buf_size = PAGE_SIZE, n_written, tot_written; struct list_head *cur; if (!channel) return -ENODEV; + mutex_lock(&vmbus_connection.channel_mutex); + tot_written = snprintf(buf, buf_size, "%u:%u\n", channel->offermsg.child_relid, channel->target_cpu); - spin_lock_irqsave(&channel->lock, flags); - list_for_each(cur, &channel->sc_list) { if (tot_written >= buf_size - 1) break; @@ -532,7 +531,7 @@ static ssize_t channel_vp_mapping_show(struct device *dev, tot_written += n_written; } - spin_unlock_irqrestore(&channel->lock, flags); + mutex_unlock(&vmbus_connection.channel_mutex); return tot_written; } -- 2.25.1