Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp600686ybt; Fri, 19 Jun 2020 09:05:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPi9Rse3Cd8m4mo/nopSTbdw5om9vCSVcfYHpYkBe/TydbBbsPISpFni8Il6yFdZrxoOdV X-Received: by 2002:a17:906:d933:: with SMTP id rn19mr4446718ejb.158.1592582709016; Fri, 19 Jun 2020 09:05:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592582709; cv=none; d=google.com; s=arc-20160816; b=iXDPId5WNNKWNy5vLEaNYW1t5uTBFpgQW+L1j/sptadY685jisHDz3ZnLuonVIXmu+ jQrqYZM2e9BmWdW8xd4ph6ayML/J2VjDda1pr7DWNqc1lyYrffR+3qJaFimELxLPY6rg oucjP72gc2lU4QuA9v3KzBhViREhE0xkC/GTJhe9wnjyyZZL+WoCvuKgg7h9ehtUJ89d lEtuv+gI6CWjiARBaHUPsLk61n3W4jXGfoMYECXHlkjkvvcHukSiuRdsx88ywjcbF+it wxMIOcI47xok4jNkrSDipp0rM47ObZ9wYGl+6aO2YSRyZU4RR76MM0cOqz9/TtnOXQE3 uoOw== 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; bh=igRhbYLV+7PJ6N9DkBcYUmMXd50ZJc1tlq0/bt0/vSM=; b=yHeUlnKGBT6Cy0A9KcrCz/jq02+JWe2mkTD2hBx9MUjElZx21V+zFrN5EkbAa6usV/ zSp1WDuNlHQg7OZgQWAHsdBZpDKIZ8SmphxW7KvbsQtwoFBy4HTC07BdoFtjcET71no8 aikcFgKz/5TXktjyZicnD2piMSG1b83F5a3ZG9uMiiYASayqHpoc9UkjmyV8hdDpBRzE 8CwHjx525y7hOAD7N6rvxKkyw7bI3MNOrEKNOjDHg4FHUjHIJVVMhqv88ie5DKK5vFsb eBFjY8Wi0TVnvKQmvThrWbHfW+dO/cbnT6ebkVF1usD6Z4VP/HlMGQUizc2vQBa9SqJK THfw== ARC-Authentication-Results: i=1; mx.google.com; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e5si4071662eja.364.2020.06.19.09.04.45; Fri, 19 Jun 2020 09:05:09 -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; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404231AbgFSQBr (ORCPT + 99 others); Fri, 19 Jun 2020 12:01:47 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:33714 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392228AbgFSQBl (ORCPT ); Fri, 19 Jun 2020 12:01:41 -0400 Received: by mail-wr1-f66.google.com with SMTP id l11so10219054wru.0; Fri, 19 Jun 2020 09:01:39 -0700 (PDT) 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=igRhbYLV+7PJ6N9DkBcYUmMXd50ZJc1tlq0/bt0/vSM=; b=nXEjci27uYDnoG14W1QNAqoNXY4/B4lcikwcOWWT8xah2FV7c6zCaXca63OkQw2tYL QHJOKqIcZh0PLCBc/TPsLlAaCN0tkc42l0fWMspGcYHZ9vt6Kn3z3Fnz9NTmQvWRDFLg vXGTGsNZK4z6HvJV2eKYEcsLzk1w6AES21hjTMNlm4g1jNKCRZJ11cZr9Vff2SHiW8dX urYMeLd9cbKN0aELd52Hu2CpdO9ZLJkh4UZttb33hQJ1xMz/XcNnqBoh5N9cYtwQinGx EjFhjHS9fBf8bdakfVeeQWHblC31lZStkgRXuJxi8a6LKAFLzuqVSSbi3hhcSbpd4pEd lczg== X-Gm-Message-State: AOAM5316dh20f99sfSFm7Sv9rRgAsKZmaBp/yA7Ype66BVwYclQFJsce +AUN5rBcAvEoYfI01ZEsHR0= X-Received: by 2002:a5d:5605:: with SMTP id l5mr4704895wrv.318.1592582498803; Fri, 19 Jun 2020 09:01:38 -0700 (PDT) Received: from liuwe-devbox-debian-v2 ([51.145.34.42]) by smtp.gmail.com with ESMTPSA id o82sm7393169wmo.40.2020.06.19.09.01.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jun 2020 09:01:37 -0700 (PDT) Date: Fri, 19 Jun 2020 16:01:36 +0000 From: Wei Liu To: "Andrea Parri (Microsoft)" , "James E.J. Bottomley" , "Martin K. Petersen" Cc: "K . Y . Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Michael Kelley , linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org Subject: Re: [PATCH 7/8] scsi: storvsc: Introduce the per-storvsc_device spinlock Message-ID: <20200619160136.2r34bdu26hxixv7l@liuwe-devbox-debian-v2> References: <20200617164642.37393-1-parri.andrea@gmail.com> <20200617164642.37393-8-parri.andrea@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200617164642.37393-8-parri.andrea@gmail.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Cc SCSI maintainers This patch should go via the hyperv tree because a later patch is dependent on it. It requires and ack from SCSI maintainers though. Thanks, Wei. On Wed, Jun 17, 2020 at 06:46:41PM +0200, Andrea Parri (Microsoft) wrote: > storvsc uses the spinlock of the hv_device's primary channel to > serialize modifications of stor_chns[] performed by storvsc_do_io() > and storvsc_change_target_cpu(), when it could/should use a (per-) > storvsc_device spinlock: this change untangles the synchronization > mechanism for the (storvsc-specific) stor_chns[] array from the > "generic" VMBus code and data structures, clarifying the scope of > this synchronization mechanism. > > Signed-off-by: Andrea Parri (Microsoft) > --- > drivers/scsi/storvsc_drv.c | 16 +++++++++++----- > 1 file changed, 11 insertions(+), 5 deletions(-) > > diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c > index 072ed87286578..8ff21e69a8be8 100644 > --- a/drivers/scsi/storvsc_drv.c > +++ b/drivers/scsi/storvsc_drv.c > @@ -462,6 +462,11 @@ struct storvsc_device { > * Mask of CPUs bound to subchannels. > */ > struct cpumask alloced_cpus; > + /* > + * Serializes modifications of stor_chns[] from storvsc_do_io() > + * and storvsc_change_target_cpu(). > + */ > + spinlock_t lock; > /* Used for vsc/vsp channel reset process */ > struct storvsc_cmd_request init_request; > struct storvsc_cmd_request reset_request; > @@ -639,7 +644,7 @@ static void storvsc_change_target_cpu(struct vmbus_channel *channel, u32 old, > return; > > /* See storvsc_do_io() -> get_og_chn(). */ > - spin_lock_irqsave(&device->channel->lock, flags); > + spin_lock_irqsave(&stor_device->lock, flags); > > /* > * Determines if the storvsc device has other channels assigned to > @@ -676,7 +681,7 @@ static void storvsc_change_target_cpu(struct vmbus_channel *channel, u32 old, > WRITE_ONCE(stor_device->stor_chns[new], channel); > cpumask_set_cpu(new, &stor_device->alloced_cpus); > > - spin_unlock_irqrestore(&device->channel->lock, flags); > + spin_unlock_irqrestore(&stor_device->lock, flags); > } > > static void handle_sc_creation(struct vmbus_channel *new_sc) > @@ -1433,14 +1438,14 @@ static int storvsc_do_io(struct hv_device *device, > } > } > } else { > - spin_lock_irqsave(&device->channel->lock, flags); > + spin_lock_irqsave(&stor_device->lock, flags); > outgoing_channel = stor_device->stor_chns[q_num]; > if (outgoing_channel != NULL) { > - spin_unlock_irqrestore(&device->channel->lock, flags); > + spin_unlock_irqrestore(&stor_device->lock, flags); > goto found_channel; > } > outgoing_channel = get_og_chn(stor_device, q_num); > - spin_unlock_irqrestore(&device->channel->lock, flags); > + spin_unlock_irqrestore(&stor_device->lock, flags); > } > > found_channel: > @@ -1881,6 +1886,7 @@ static int storvsc_probe(struct hv_device *device, > init_waitqueue_head(&stor_device->waiting_to_drain); > stor_device->device = device; > stor_device->host = host; > + spin_lock_init(&stor_device->lock); > hv_set_drvdata(device, stor_device); > > stor_device->port_number = host->host_no; > -- > 2.25.1 >