Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3002699imu; Sun, 9 Dec 2018 14:50:04 -0800 (PST) X-Google-Smtp-Source: AFSGD/Xa/Dqkp34rBdlKlM/jtQZxN1haSicZyXLbTUqrsdf2XrWNMDp2Jc99bjALzd4ZEwmD/UzV X-Received: by 2002:a17:902:5a0b:: with SMTP id q11mr10076475pli.186.1544395804935; Sun, 09 Dec 2018 14:50:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544395804; cv=none; d=google.com; s=arc-20160816; b=jrBH3o5icm+nOvUh7U6+3aAPBFsveBCpccBkbTd+Tn5sRHRlio4H5KnDOpPR48SUc5 wrkZjYJOi1+VsYEfIxz6ZudEkgP4lZ5caN6KRhS8vvEDXe7xA5AyfKQ1kqlpSbFgaDBa FDRSf101RlDmRQ34nm27fzJ6qa/Bf5cID1MUdEX6bXbpjhiVSknjbwzCwsKDKKdOLFy3 sHw//GtaexzKPPBN4Jy/+GZ8vONeh5WEsI8G09qSWLgWfFGUh2zFvPJ2EoY0iTbZoA80 R8aFvF2zxWLmCsy2mZwt/z6UGOOA4WTyW/6h1GChIEELYThxKKZwh6ANCrSlQS9m27fG d9LA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=1wwT1Cfej/u5a6yyAjbn5bJsOakwaRfpWMCsj5LMEyk=; b=yOhwr/hn2aW487tsTH1AzsBEyDrAOxD8gJUqwXGYLOk2JnH1Z3unj1vC8K3odMPD2s c5S5BuTNqKcsB717wHjADrdHliwRsERspV1oTGaNLl3u9nZClwwgSxaLazRpGR2pMkw6 EEIqsqim+3IDcoJhIoatc2jSjs6roN6KvqcamykUph+8o/qR0LHLxl5zDXLOlnbqyEIk eU64DwZM6rVrIGo6Kva6NQp+YvvweUngZ82H0o7+zTVPDLGSgY/6Kc5/S8JfYkF5zKTL +BLRrgsvbPulNABCIFdNiLnDcVfCvt2kIrcIql0JRg2Vs9rqOuhZLvYyZZIewoE8df8r Mg7Q== 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 e2si6233500pgs.94.2018.12.09.14.49.49; Sun, 09 Dec 2018 14:50:04 -0800 (PST) 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 S1727167AbeLIWCp (ORCPT + 99 others); Sun, 9 Dec 2018 17:02:45 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:35816 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726646AbeLIVzb (ORCPT ); Sun, 9 Dec 2018 16:55:31 -0500 Received: from pub.yeoldevic.com ([81.174.156.145] helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gW72u-0002ir-7z; Sun, 09 Dec 2018 21:55:28 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gW72j-0003d6-W1; Sun, 09 Dec 2018 21:55:17 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Dexuan Cui" , "Greg Kroah-Hartman" , "Haiyang Zhang" , "Stephen Hemminger" , "K. Y. Srinivasan" Date: Sun, 09 Dec 2018 21:50:33 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 279/328] Drivers: hv: vmbus: Use get/put_cpu() in vmbus_connect() In-Reply-To: X-SA-Exim-Connect-IP: 81.174.156.145 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.62-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Dexuan Cui commit 41e270f6898e7502be9fd6920ee0a108ca259d36 upstream. 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: K. Y. Srinivasan Cc: Haiyang Zhang Cc: Stephen Hemminger Signed-off-by: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman [bwh: Backported to 3.16: - smp_processor_id() is only used once here - Adjust context] Signed-off-by: Ben Hutchings --- drivers/hv/connection.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/drivers/hv/connection.c +++ b/drivers/hv/connection.c @@ -68,6 +68,7 @@ static int vmbus_negotiate_version(struc __u32 version) { int ret = 0; + unsigned int cur_cpu; struct vmbus_channel_initiate_contact *msg; unsigned long flags; @@ -80,8 +81,11 @@ static int vmbus_negotiate_version(struc msg->interrupt_page = virt_to_phys(vmbus_connection.int_page); msg->monitor_page1 = virt_to_phys(vmbus_connection.monitor_pages[0]); msg->monitor_page2 = virt_to_phys(vmbus_connection.monitor_pages[1]); - if (version == VERSION_WIN8_1) - msg->target_vcpu = hv_context.vp_index[smp_processor_id()]; + if (version == VERSION_WIN8_1) { + cur_cpu = get_cpu(); + msg->target_vcpu = hv_context.vp_index[cur_cpu]; + put_cpu(); + } /* * Add to list before we send the request since we may