From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932268Ab0CDUCC (ORCPT ); Thu, 4 Mar 2010 15:02:02 -0500 Received: from ogre.sisk.pl ([217.79.144.158]:49200 "EHLO ogre.sisk.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932149Ab0CDUCA (ORCPT ); Thu, 4 Mar 2010 15:02:00 -0500 From: "Rafael J. Wysocki" To: Alan Stern Subject: Re: [linux-pm] Is it supposed to be ok to call del_gendisk while userspace is frozen? Date: Thu, 4 Mar 2010 21:04:39 +0100 User-Agent: KMail/1.12.4 (Linux/2.6.33-git-rjw; KDE/4.3.5; x86_64; ; ) Cc: Pavel Machek , Jens Axboe , Maxim Levitsky , "linux-pm" , "linux-kernel" , Andrew Morton References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201003042104.39600.rjw@sisk.pl> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thursday 04 March 2010, Alan Stern wrote: > On Thu, 4 Mar 2010, Rafael J. Wysocki wrote: > > > On Thursday 04 March 2010, Alan Stern wrote: > > > On Thu, 4 Mar 2010, Rafael J. Wysocki wrote: > > > > > > > > Very well. Then we still need a solution to the original problem: > > > > > Devices sometimes need to be unregistered during resume, but > > > > > del_gendisk() blocks on the writeback thread, which is frozen until > > > > > after the resume finishes. How do you suggest this be fixed? > > > > > > > > I thought about thawing the writeback thread earlier in such cases. > > > > > > > > Would that makes sense / is it doable at all? > > > > > > My thought exactly. This is the only approach that also solves the > > > following race: > > > > > > A driver is unloaded at the same time as a suspend starts. > > > > > > The writeback thread gets frozen. > > > > > > Then before the rmmod thread is frozen, it calls del_gendisk. > > > > > > Delaying things by means of a workqueue (or the equivalent) might also > > > work, but it doesn't seem as safe. For example, some important > > > writebacks might end up getting delayed until too late. > > > > OK, so what exactly should trigger the thawing of the writeback thread? > > > > Should we do that unconditionally at one point or wait for a specific situation > > to happen, and how to recognize that situation in the latter case? > > My thought was that del_gendisk would do this unconditionally. It > would make the task unfreezable and then thaw it, to prevent a race. > > This assumes that del_gendisk never gets called in the middle of a > sleep transition unless the device is really gone. Well, I guess we can make it a rule. Or use a flag that will be set to 'true' during resume (early) and will tell del_gendisk whether to thaw the writeback thread. Rafael