Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp678569ybl; Wed, 11 Dec 2019 05:56:36 -0800 (PST) X-Google-Smtp-Source: APXvYqzfKsbER9KyQko0LzTELZAyngJbJDjBzQVCF8Zlix+Zq7Z8jwyRAFyvn3vX/O9irge18nSj X-Received: by 2002:a9d:6196:: with SMTP id g22mr2421675otk.204.1576072596381; Wed, 11 Dec 2019 05:56:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576072596; cv=none; d=google.com; s=arc-20160816; b=Usyj1fnGz0qu3bRIhXjGlAwOMaDqBkJkoMa8ydYk57fxbSBH9yetmeTOj7z0CjzPbT 1CjNW4p1Vt3Y/AlbCMrVnu1mOzEr242yJ2I3kdrNeg/Q2un22oeplOknzsGSfpnsEZr4 xzlvXZXC4+ag3l4av2YwQ76193j2vt7b6oZu7IDICz/rWjF+R4PdwUs5nrh7eZ+XEmdb bcWpwUbcXllHqZmJE4cCxJTDQNswWU93MUlboE4t3EJradipNoVhlmM/ZSh1iubuimLM 6hP8vEoF6af/bhCUOTWp/3Bx2w8GOfwcMfOAuAgKwSwjZNRoOsNlDGqj/9TxSlzBp8Lt JKVw== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:ironport-sdr :dkim-signature; bh=tppD+8fZEgY7c0JJPlEmURWJ8Xm6VFv4pi932gkNozE=; b=Bt8JZhE7UfhKNX8D2M5ACUY90CVev/oMOiDf5HezOlEQzavHadBk2t7KBwZbNwIFfm 9L5qYyHmVVqURYL+mg4uRF1kORhgeiKWvgkbVHh9igSWWYXpLW2hgdO3rDsNzsdwLXt6 9Psw63cnpDkg/9mxyo+os9JopLqGx52GlqRp0HXj/cD4MrWHzuHfURH7MYR+rHBMgjgx AgFiDyYSPcYfHm14CDTMpMyKfhu00GcVuutH23RNC86LyjSFo5A4BXzi3JJufz5/QTPJ Wl1otT8fLNY4RpNvmJaGqG48pHal+nhRBR6unSIGdkdzl7MzTMb6zMnWn6/xadLih8dx d90w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@citrix.com header.s=securemail header.b=gXCCmURF; 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=fail (p=NONE sp=NONE dis=NONE) header.from=citrix.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h138si1096936oib.6.2019.12.11.05.56.23; Wed, 11 Dec 2019 05:56:36 -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=fail header.i=@citrix.com header.s=securemail header.b=gXCCmURF; 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=fail (p=NONE sp=NONE dis=NONE) header.from=citrix.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729608AbfLKNzp (ORCPT + 99 others); Wed, 11 Dec 2019 08:55:45 -0500 Received: from esa2.hc3370-68.iphmx.com ([216.71.145.153]:34948 "EHLO esa2.hc3370-68.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727554AbfLKNzp (ORCPT ); Wed, 11 Dec 2019 08:55:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1576072544; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=m6R/VVoQ+gbtGku3qSSn8lR/7efTsyljc6KkleafnFc=; b=gXCCmURFNgUXUl1t8lYwEKOMJy03AqyqJ+JUkD3gekgjB45+1eom6T26 SsRw5Q+PIb5Ect47BgTH0Ye/Tp6V4OpRcKO89TPsvpvqWq6Kpt0IOov08 XBhF9KJ3/IpjpF336b0J9PNmWF2vx+3SySf56Vc8e5M+s4T9K1ZjT5TH3 c=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=roger.pau@citrix.com; spf=Pass smtp.mailfrom=roger.pau@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa2.hc3370-68.iphmx.com: no sender authenticity information available from domain of roger.pau@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="roger.pau@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa2.hc3370-68.iphmx.com: domain of roger.pau@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="roger.pau@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa2.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: Re26XLu4wVkXUyQDl8HBVkOhLeyFLmQmgQTYX/F9xkWTCyCe72gIZikKm6tF3tt6LGPzXB7BMB OZrpVZVwrxPp+9dIKp8TmrhWU15IKf+Rxd8GXKNkzkbmmCaTtwW02zr+1AlI7hpua044e9Fk3J K0YNEqd4y/MEPLJgiCtuz501SpJJQm2a5pEorJKjlJJFmJs0CHTGcyq7C5/ig0Ie0XfWATCVpJ vy/KvmibcHM5BzacenYFyom3Vv5LKDcRs02GwOHtVkttOwWEUp5BuchIQTaYAmxDTT1B/X9YMH eaY= X-SBRS: 2.7 X-MesageID: 9529409 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,301,1571716800"; d="scan'208";a="9529409" Date: Wed, 11 Dec 2019 14:55:23 +0100 From: Roger Pau =?iso-8859-1?Q?Monn=E9?= 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 Message-ID: <20191211135523.GP980@Air-de-Roger> References: <20191210145305.6605-1-pdurrant@amazon.com> <20191211112754.GM980@Air-de-Roger> <14a01d62046c48ee9b2486917370b5f5@EX13D32EUC003.ant.amazon.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <14a01d62046c48ee9b2486917370b5f5@EX13D32EUC003.ant.amazon.com> User-Agent: Mutt/1.12.2 (2019-09-21) X-ClientProxiedBy: AMSPEX02CAS02.citrite.net (10.69.22.113) To AMSPEX02CL03.citrite.net (10.69.22.127) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 11, 2019 at 01:27:42PM +0000, Durrant, Paul wrote: > > -----Original Message----- > > From: Roger Pau Monn? > > 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? > > > > One nit below. > > > > > --- > > > Cc: Konrad Rzeszutek Wilk > > > Cc: "Roger Pau Monn?" > > > 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 = 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? 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. Thanks, Roger.