From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752004AbeA0ENv (ORCPT ); Fri, 26 Jan 2018 23:13:51 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:41430 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751677AbeA0ENu (ORCPT ); Fri, 26 Jan 2018 23:13:50 -0500 X-Google-Smtp-Source: AH8x224SvFoGYNyvD9XlV3Ul9tHvkdCclIWbNLpvfESLE2C+JseGn5hydzI7aavLfy8L43BcSHrxGQ== Subject: Re: [PATCH] block: paride: on26: Replace mdelay with msleep in on26_test_port To: Al Viro Cc: tim@cyberelk.net, linux-kernel@vger.kernel.org References: <1516981345-8202-1-git-send-email-baijiaju1990@gmail.com> <20180126173130.GZ13338@ZenIV.linux.org.uk> From: Jia-Ju Bai Message-ID: <2a3f0d10-824b-0d26-0046-6379a363b383@gmail.com> Date: Sat, 27 Jan 2018 12:13:30 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: <20180126173130.GZ13338@ZenIV.linux.org.uk> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018/1/27 1:31, Al Viro wrote: > On Fri, Jan 26, 2018 at 11:42:25PM +0800, Jia-Ju Bai wrote: >> After checking all possible call chains to on26_test_port() here, >> my tool finds that this function is never called in atomic context, >> namely never in an interrupt handler or holding a spinlock. >> And on26_test_port() is only called by pi_probe_unit() that calls >> wait_event() through pi_claim(), >> so it indicates that on26_test_port() can call functions that can sleep. >> Thus mdelay can be replaced with msleep to avoid busy wait. > Sigh... Here's how I would've written it: > > " > on26_test_port() is never called from atomic contexts. > > It has no direct callers and it is reachable only via ->test_port. > ->test_port has only one user: > drivers/block/paride/paride.c:322: max = pi->proto->test_port(pi); > in pi_probe_unit(). That gets called only from pi_init(), called from > p{d,cd,f,t,g}_detect(), called from module_init stuff, all of the above > without entering atomic contexts along the way. > > Despite never getting called from atomic contexts, on26_test_port() contains > mdelay(100), i.e. busy-loops for 0.1s; that's neither nice nor needed, since > msleep() would serve just as well. > > Found by [reference to tool]" Okay, thanks for your patient guidance :) I will revise the description and send v2 patch, and follow the advice in my next patches. Thanks, Jia-Ju Bai