Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp681564ybl; Wed, 11 Dec 2019 06:00:05 -0800 (PST) X-Google-Smtp-Source: APXvYqyzbFjIx9T5GHdmM72m3qikaqyRfn+4yuOrp5C5vvSiE3tV4Qr9GZsy6vdSJPfIjtB0NxGo X-Received: by 2002:aca:2808:: with SMTP id 8mr2949706oix.27.1576072805408; Wed, 11 Dec 2019 06:00:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576072805; cv=none; d=google.com; s=arc-20160816; b=xTwRt1LLGpgH3onQRrK50Cod0/aZxc27lfzgfS9A4ynTc+r/JCrYKOtW+C2lcIcIX7 B1now5o+DsfGPDFQQ7yLFSE4LLReaXMu8G02tmCSWDYSuKXIfTg1hu2WG57aHlNQYXKK jCETXM0O8odkG+RVLeYOoQmKqSscCr4MNyQK8roMbTbLgKu1latmGmd3OuKYWYky/uha oGNIIOzIuQJEKupVDklgWYELMBecP2GIEl35HT4zvigcsj2KpbAS2U8Nh0t8Umjtg9P0 PCTgJAR+rRdMa+x7fglzQCgo2cR9J3baQA3hxYCZJS4Mw3DyCAv+q1Hud1aItiZfCQxc YF3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:ironport-sdr :dkim-signature; bh=W8TTi/2IIEXbPsGUA9DEIj5AQ0RHJuHWIGTOmHVUQus=; b=YbUOQkrr40Pie0FPvaXC5DO0S++30ql9XlZODz5+j+e6CoIWObFL/NFoeioqNd2JaT 6pqiv++I7cSFZg7na/s2XU5HVmP8p2FvPBMjxhIrLFzmiIj65GqCtBeOry/VpxOY0Xvl hjYe7DPEvq8IVOONcrxU42KtUK5ePKp4Ejts6PzFw1LR3/NQO0uAPvY/L+CK3XVzBzky SWRb/djXkxT645PFoPU9aJ5BAYVRj914NCEb9m2Qih/KZHXvUnFcU6XR9ivk+0+GdkBe QGmMhAKszuA0SAy92KLl+kdCfJdykKrdKRiD6GlWqHvAdnuXVIEujj78lsmA1FisCqam ItLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=pLF6+ECJ; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h11si1233418otr.197.2019.12.11.05.59.52; Wed, 11 Dec 2019 06:00:05 -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; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=pLF6+ECJ; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729705AbfLKN6D (ORCPT + 99 others); Wed, 11 Dec 2019 08:58:03 -0500 Received: from smtp-fw-9101.amazon.com ([207.171.184.25]:38463 "EHLO smtp-fw-9101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728128AbfLKN6D (ORCPT ); Wed, 11 Dec 2019 08:58:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1576072682; x=1607608682; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=W8TTi/2IIEXbPsGUA9DEIj5AQ0RHJuHWIGTOmHVUQus=; b=pLF6+ECJZtqBNaM3K4bnY13fxpzUOh5lElBDTq3fONH549VhWM+TCnnT bfZwXkHHtcF0/gkTHM5Vf3T9l72Pfpfj1PzVuslTpe+jnCAHj4B73wQSI 8+MsXA0gQW++m9t1xTOtCDJYBuh9saAvI2sGrOE4ZdkQjyV+rp/ghZGvg o=; IronPort-SDR: mkmquFRZdQ8fhag+H0SlzhM9qj48wmtmu0VhkeL9obp3+XTB70l/s1tnfYtMUyjId7XwSWkwiv Nb2KZPkVlIvA== X-IronPort-AV: E=Sophos;i="5.69,301,1571702400"; d="scan'208";a="4498934" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-2b-5bdc5131.us-west-2.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-9101.sea19.amazon.com with ESMTP; 11 Dec 2019 13:57:44 +0000 Received: from EX13MTAUEA001.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan3.pdx.amazon.com [10.170.41.166]) by email-inbound-relay-2b-5bdc5131.us-west-2.amazon.com (Postfix) with ESMTPS id 38FCAA2707; Wed, 11 Dec 2019 13:57:44 +0000 (UTC) Received: from EX13D32EUC003.ant.amazon.com (10.43.164.24) by EX13MTAUEA001.ant.amazon.com (10.43.61.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 11 Dec 2019 13:57:43 +0000 Received: from EX13D32EUC003.ant.amazon.com (10.43.164.24) by EX13D32EUC003.ant.amazon.com (10.43.164.24) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 11 Dec 2019 13:57:42 +0000 Received: from EX13D32EUC003.ant.amazon.com ([10.43.164.24]) by EX13D32EUC003.ant.amazon.com ([10.43.164.24]) with mapi id 15.00.1367.000; Wed, 11 Dec 2019 13:57:42 +0000 From: "Durrant, Paul" To: =?iso-8859-1?Q?Roger_Pau_Monn=E9?= , Juergen Gross CC: "xen-devel@lists.xenproject.org" , "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Konrad Rzeszutek Wilk" , Jens Axboe Subject: RE: [PATCH] xen-blkback: prevent premature module unload Thread-Topic: [PATCH] xen-blkback: prevent premature module unload Thread-Index: AQHVr2mJT7izwmimDUiZW3emm6kz0qe0zXcAgAAhBkCAAAfzgIAAAGuQ Date: Wed, 11 Dec 2019 13:57:42 +0000 Message-ID: <4c9a0d81d0634f27a41fe10c8d93a4ea@EX13D32EUC003.ant.amazon.com> References: <20191210145305.6605-1-pdurrant@amazon.com> <20191211112754.GM980@Air-de-Roger> <14a01d62046c48ee9b2486917370b5f5@EX13D32EUC003.ant.amazon.com> <20191211135523.GP980@Air-de-Roger> In-Reply-To: <20191211135523.GP980@Air-de-Roger> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.43.164.172] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > -----Original Message----- > From: Roger Pau Monn=E9 > Sent: 11 December 2019 13:55 > To: Durrant, Paul ; Juergen Gross > Cc: xen-devel@lists.xenproject.org; linux-block@vger.kernel.org; linux- > kernel@vger.kernel.org; Konrad Rzeszutek Wilk ; > Jens Axboe > Subject: Re: [PATCH] xen-blkback: prevent premature module unload >=20 > On Wed, Dec 11, 2019 at 01:27:42PM +0000, Durrant, Paul wrote: > > > -----Original Message----- > > > From: Roger Pau Monn=E9 > > > Sent: 11 December 2019 11:29 > > > To: Durrant, Paul > > > Cc: xen-devel@lists.xenproject.org; linux-block@vger.kernel.org; > linux- > > > kernel@vger.kernel.org; Konrad Rzeszutek Wilk > ; > > > Jens Axboe > > > Subject: Re: [PATCH] xen-blkback: prevent premature module unload > > > > > > On Tue, Dec 10, 2019 at 02:53:05PM +0000, Paul Durrant wrote: > > > > Objects allocated by xen_blkif_alloc come from the 'blkif_cache' > kmem > > > > cache. This cache is destoyed when xen-blkif is unloaded so it is > > > > necessary to wait for the deferred free routine used for such > objects to > > > > complete. This necessity was missed in commit 14855954f636 "xen- > blkback: > > > > allow module to be cleanly unloaded". This patch fixes the problem > by > > > > taking/releasing extra module references in xen_blkif_alloc/free() > > > > respectively. > > > > > > > > Signed-off-by: Paul Durrant > > > > > > Reviewed-by: Roger Pau Monn=E9 > > > > > > One nit below. > > > > > > > --- > > > > Cc: Konrad Rzeszutek Wilk > > > > Cc: "Roger Pau Monn=E9" > > > > Cc: Jens Axboe > > > > --- > > > > drivers/block/xen-blkback/xenbus.c | 10 ++++++++++ > > > > 1 file changed, 10 insertions(+) > > > > > > > > diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen= - > > > blkback/xenbus.c > > > > index e8c5c54e1d26..59d576d27ca7 100644 > > > > --- a/drivers/block/xen-blkback/xenbus.c > > > > +++ b/drivers/block/xen-blkback/xenbus.c > > > > @@ -171,6 +171,15 @@ static struct xen_blkif > *xen_blkif_alloc(domid_t > > > domid) > > > > blkif->domid =3D domid; > > > > atomic_set(&blkif->refcnt, 1); > > > > init_completion(&blkif->drain_complete); > > > > + > > > > + /* > > > > + * Because freeing back to the cache may be deferred, it is > not > > > > + * safe to unload the module (and hence destroy the cache) > until > > > > + * this has completed. To prevent premature unloading, take an > > > > + * extra module reference here and release only when the > object > > > > + * has been free back to the cache. > > > ^ freed > > > > Oh yes. Can this be done on commit, or would you like me to send a v2? >=20 > Adjusting on commit would be fine for me, but it's up to Juergen since > he is the one that will pick this up. IIRC the module unload patches > didn't go through the block subsystem. True. I forgot manually add Juergen cc list. Paul >=20 > Thanks, Roger.