Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp2734680pxt; Mon, 9 Aug 2021 07:43:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPERow5hyN9Jnh37LQwb4czgxW/GsBYR9UIYPFC7HUSSI1SckJfkm1fpTwN6ezJFuxDAmX X-Received: by 2002:aa7:c5c4:: with SMTP id h4mr6437029eds.108.1628520215148; Mon, 09 Aug 2021 07:43:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628520215; cv=none; d=google.com; s=arc-20160816; b=tlFNVniwo+UzKwS6D+9/3gWS1MB4o4BzAq3EZudMZVVJigfEzYD1C1tGYVmsOJTgCK OJxL7XLXWYvmALPqpOyjInIFPomruzV7n34pMAhy/MtBwWJ1uB87wEyY49G80VtZMbD5 zU9KFUL3Alplt+8FHr6lP972ZPfUWfHb/8C+gGwPxMG8Mbsw5thffPpkDNH5+5XSK7o7 lWABRYOzNHMLTyQ3lupOjhK7aYhYazSJmdm4PgH8f56KHyt2yauxcBlbBHxqZZVGgZRJ FzgEkwMt+9AchSR9QEyZPsiM82VTDxsFvPIpZcXRyqOhdX3yFEERpZvWPt6FxktIkZsN /7qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=1wiQTuXzLwIdPR9pB/jCD6NIhMMJYAS4OSbUhVxuWnI=; b=OSNKi76Xf+5Mdoa4soWqS/d3eFVsO3cnVYziJIjw3dqGGrQyyOdT0GtmuvKos4CDVW UK2b8CW/5DYw0bCLC6YFqNJoksI3bc1bsAR5iRHFa5phRdAq9bIcsCxZpt3mAP9fOaLM noYN/F7kvUySyMsQC3+DoWUASx7Cl8Ayr7sJSisn/hpFiSIV8BPxz3ON2kXeY1XAs8cN XcxfoFf4is5GzS52dlE0mpO+ljR6qEBMIkjrmE5fK9+uWYpooIBMpSGMVArKRf6yU7eb fFyz+sCDUpNEBCyyZwdYpVR8on1a6sPnUpfKt5A2uEbrF5iLvJi9anqV93BD9iT/VQ0F D22g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ka11si17564579ejc.367.2021.08.09.07.43.10; Mon, 09 Aug 2021 07:43:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235307AbhHIOfe (ORCPT + 99 others); Mon, 9 Aug 2021 10:35:34 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:13301 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234254AbhHIOd4 (ORCPT ); Mon, 9 Aug 2021 10:33:56 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Gjz2t49Pbz84Qv; Mon, 9 Aug 2021 22:28:22 +0800 (CST) Received: from dggema774-chm.china.huawei.com (10.1.198.216) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Mon, 9 Aug 2021 22:33:19 +0800 Received: from [10.67.102.197] (10.67.102.197) by dggema774-chm.china.huawei.com (10.1.198.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Mon, 9 Aug 2021 22:33:18 +0800 Subject: Re: [PATCH] semaphore: Add might_sleep() to down_*() family To: Waiman Long , , , , , CC: , , References: <20210809021215.19991-1-nixiaoming@huawei.com> <48cddad4-0388-ae8b-f98b-1629b9ae590a@redhat.com> <1a5b0f50-b071-2d1c-5277-b6d7f652c257@huawei.com> <65fe396a-b10d-2388-8229-05fd43d58927@redhat.com> From: Xiaoming Ni Message-ID: <2266017d-df76-1208-0e1f-0b066c788f66@huawei.com> Date: Mon, 9 Aug 2021 22:33:18 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.0.1 MIME-Version: 1.0 In-Reply-To: <65fe396a-b10d-2388-8229-05fd43d58927@redhat.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.102.197] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggema774-chm.china.huawei.com (10.1.198.216) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/8/9 20:52, Waiman Long wrote: > On 8/8/21 11:51 PM, Xiaoming Ni wrote: >> On 2021/8/9 11:01, Waiman Long wrote: >>> >>> I think it is simpler to just put a "might_sleep()" in >>> __down_common() which is the function where sleep can actually happen. >>> >> >> If the actual atomic context hibernation occurs, the corresponding >> alarm log is generated in __schedule_bug(). >>     __schedule() >>         --> schedule_debug() >>             --> __schedule_bug() >> >> However, "might_sleep()" indicates the possibility of sleep, so that >> code writers can identify and fix the problem as soon as possible, but >> does not trigger atomic context sleep. >> >> Is it better to put "might_sleep()" in each down API entry than >> __down_common() to help identify potential code problems? > > Putting "might_sleep()" in each down_*() functions mean that whenever we > add a new API function, we have to remember to add "might_sleep()". If > we put it in down_common(), it will work for any newly added API > function in the future even though I doubt we will add any. > If the code enters down_common(), it is not "might" sleep but "will" sleep, and an alarm is printed in __schedule_bug() later. "might_sleep()" is used to check potential problems, and "_schedule_bug()" is used to check actual faults. So, I still think we should add "might_sleep()" to each down_*() function to alert code owner to potential problems early. Thanks Xiaoming Ni