From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755680AbcECNkQ (ORCPT ); Tue, 3 May 2016 09:40:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35039 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751030AbcECNkO (ORCPT ); Tue, 3 May 2016 09:40:14 -0400 Date: Tue, 3 May 2016 15:40:09 +0200 From: Oleg Nesterov To: Andrew Morton Cc: Oleksandr Natalenko , Ben Hutchings , Lee Jones , Wolfram Sang , Roger Tseng , linux-kernel@vger.kernel.org Subject: Re: [PATCH RESEND] rtsx_usb_ms: Use msleep_interruptible() in polling loop Message-ID: <20160503134009.GA26668@redhat.com> References: <7afcd6e57d09772699ac37b59db98617@natalenko.name> <20160502135634.ccbfb7f58798b7a217319b98@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160502135634.ccbfb7f58798b7a217319b98@linux-foundation.org> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/02, Andrew Morton wrote: > > On Mon, 02 May 2016 23:17:41 +0300 Oleksandr Natalenko wrote: > > > rtsx_usb_ms creates a task that mostly sleeps, but tasks in > > uninterruptible sleep still contribute to the load average (for > > bug-compatibility with Unix). We have TASK_NOLOAD/TASK_IDLE, you can just use schedule_timeout_idle(HZ). but msleep_interruptible(1000) is fine too. > > --- a/drivers/memstick/host/rtsx_usb_ms.c > > +++ b/drivers/memstick/host/rtsx_usb_ms.c > > @@ -706,7 +706,8 @@ poll_again: > > if (host->eject) > > break; > > > > - msleep(1000); > > + if (msleep_interruptible(1000)) > > + flush_signals(current); > > } > > > > complete(&host->detect_ms_exit); > > flush_signals() is a bit scary. ... > But this isn't a userspace task - it's a kthread. So I don't *think* > it can get any signals anyway? Agreed, it is not needed and only adds some confusion, so I think rtsx_usb_ms-use-msleep_interruptible-in-polling-loop.patch should be updated. A kernel thread ignores all signals unless it does allow_signal(), so you can safely remove flush_signals(). Oleg.