Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3526259imm; Sun, 16 Sep 2018 21:16:22 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZxUcWOSP5oDYHWSgBIOHRe/VXsiyL3ym63PPbDyXn0F9RE4R3pZWTWjU4VHTFwY4jOKqCy X-Received: by 2002:a63:5a4e:: with SMTP id k14-v6mr22101121pgm.297.1537157782156; Sun, 16 Sep 2018 21:16:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537157782; cv=none; d=google.com; s=arc-20160816; b=ooBKGTaw+mVXJoeKiBncZXohasj6qNGvjxrvWhKSinBSuSQaUw/Lmm9kFcBdzAFXkZ +Xq8+6yvKSDWehUx6kGU9BNLVRNXQSGt1Nv2DSlCs5fmoRoRlF/3UfrnIav5Q0eFsxmF zLRJRXekGkNqG2qxyZQfj550XZlirwYdEcrRLp/DjwW6ZXEfN6o/SJvGfpxMl/XhuVdd RblKtyIB9+uCAUYB8X9GFLWPBlyubwLEQKRCjI0C7iQAWUv/jbK0f+vRUo4ExWNwyyms 4W0EjtR+dOyh4Wdxv0dctMR0Mx+6PcydSb0NPNMvQ4z7IkVCu/JgxrffSCfx+ODHCSEW GOcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:reply-to:references:in-reply-to :message-id:date:subject:cc:to:from; bh=WT1ap7Q+lgxJJv3kDzmPB4rbSS+031cJWE5my8cmN5k=; b=RL3y8Amy5UCMDwrft6wSz8CJ2GVIsPstiqcHN4QzmkiVXlF1Q3VeNvhiHABTdPFMK0 gX3ItlDF+EfW0fCjUylBpgqCJCLqw1payIXc5d151T3yR/C4Xplazxvgg+pnST0AWy/x FM0/4GGmXa02AO5MPuyFTXeyicqxUnVJ5dtIgj7kT1KzLimW4NGFTuEY6u0svaAxGKTc +v2XlsRkyDLfQ8VzLysqBUQHhMKoyEy3AtlMaQD5MS+/zJN1vCvLH92NtvMGFsSDhSjt enJZeXNoDXwigyNg2rmntiiLXGkr6iE0H0yxxOCp0viPWSgMgEJcGOGlPy8kMGkazCzA vubA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c18-v6si14293492pgh.530.2018.09.16.21.16.07; Sun, 16 Sep 2018 21:16:22 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728405AbeIQJlb (ORCPT + 99 others); Mon, 17 Sep 2018 05:41:31 -0400 Received: from a2nlsmtp01-03.prod.iad2.secureserver.net ([198.71.225.37]:46642 "EHLO a2nlsmtp01-03.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727224AbeIQJlb (ORCPT ); Mon, 17 Sep 2018 05:41:31 -0400 Received: from linuxonhyperv2.linuxonhyperv.com ([107.180.71.197]) by : HOSTING RELAY : with ESMTP id 1kw5ghB7wTEX41kw5gbZho; Sun, 16 Sep 2018 21:14:57 -0700 x-originating-ip: 107.180.71.197 Received: from kys by linuxonhyperv2.linuxonhyperv.com with local (Exim 4.91) (envelope-from ) id 1g1kw5-0002zU-Bi; Sun, 16 Sep 2018 21:14:57 -0700 From: kys@linuxonhyperv.com To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, devel@linuxdriverproject.org, olaf@aepfle.de, apw@canonical.com, jasowang@redhat.com, sthemmin@microsoft.com, Michael.H.Kelley@microsoft.com, vkuznets@redhat.com Cc: Dexuan Cui , stable@vger.kernel.org, "K . Y . Srinivasan" , Haiyang Zhang Subject: [PATCH 1/2] Drivers: hv: vmbus: Use get/put_cpu() in vmbus_connect() Date: Mon, 17 Sep 2018 04:14:54 +0000 Message-Id: <20180917041455.11455-1-kys@linuxonhyperv.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180917041352.11402-1-kys@linuxonhyperv.com> References: <20180917041352.11402-1-kys@linuxonhyperv.com> Reply-To: kys@microsoft.com X-CMAE-Envelope: MS4wfB7nA2z0KtHr1/sn6EmekgxkgAIwr+mUjjBwjCD57pI2y4J541XpOLP6FYv/Do2aYE8HiGWpuBn/fxcxG6+Z9QxZqfnYaT52tt8btsqQ4eN0QiopkJMA 7A2sPYbVDrMnfFNceBXz6dyLdDggGV7r7P6EvbPUKhhawFxIR9zgam0GLG+GrrFM8Qw8KvvWSr0QI++z5HsC5p4XDxsOwUcpZbkLsz+Nbnuwew2hxafFntR+ e0f55AJT8G/wGCSAAHvq1/D6sSyKtl1HcU/cT4b2Zj6e74EmxgP/jYhU6uDW83HkQCU1dmsFvIVt9ahLCbild4KmxMCJ3AuWuohDxThVr5jfMcU6lez38WDs YwYizr9vjW6M24P86WA0ZkpOaTJCbNNVeKrZq4I4q4jY9exqhkojqbj4bKz9KVi/GgSWB2uFrmxNML9rwMwzOAymXuDl+BA0fvcT2ltcjf2SFf6gKABeQleZ NQBj+3npK6rcdXsB53NN0oPcdmVLM6XAsd0s0SZlbREf6e+hwctNCTFc2FJJuB+aUrZOPUdueBEoE6imKYdWxEjLAjaUp8R/0eJImevB7POSbsIrqfYOJm1J om72PuGl/IblhhbzC3Kq/LA0yM6CQggcTBpio7BYwOaRxw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dexuan Cui With CONFIG_DEBUG_PREEMPT=y, I always see this warning: BUG: using smp_processor_id() in preemptible [00000000] Fix the false warning by using get/put_cpu(). Here vmbus_connect() sends a message to the host and waits for the host's response. The host will deliver the response message and an interrupt on CPU msg->target_vcpu, and later the interrupt handler will wake up vmbus_connect(). vmbus_connect() doesn't really have to run on the same cpu as CPU msg->target_vcpu, so it's safe to call put_cpu() just here. Signed-off-by: Dexuan Cui Cc: stable@vger.kernel.org Cc: K. Y. Srinivasan Cc: Haiyang Zhang Cc: Stephen Hemminger Signed-off-by: K. Y. Srinivasan --- drivers/hv/connection.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c index ced041899456..f4d08c8ac7f8 100644 --- a/drivers/hv/connection.c +++ b/drivers/hv/connection.c @@ -76,6 +76,7 @@ static int vmbus_negotiate_version(struct vmbus_channel_msginfo *msginfo, __u32 version) { int ret = 0; + unsigned int cur_cpu; struct vmbus_channel_initiate_contact *msg; unsigned long flags; @@ -118,9 +119,10 @@ static int vmbus_negotiate_version(struct vmbus_channel_msginfo *msginfo, * the CPU attempting to connect may not be CPU 0. */ if (version >= VERSION_WIN8_1) { - msg->target_vcpu = - hv_cpu_number_to_vp_number(smp_processor_id()); - vmbus_connection.connect_cpu = smp_processor_id(); + cur_cpu = get_cpu(); + msg->target_vcpu = hv_cpu_number_to_vp_number(cur_cpu); + vmbus_connection.connect_cpu = cur_cpu; + put_cpu(); } else { msg->target_vcpu = 0; vmbus_connection.connect_cpu = 0; -- 2.18.0