From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD6FDC636C8 for ; Wed, 21 Jul 2021 01:25:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AEBEF610F7 for ; Wed, 21 Jul 2021 01:25:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229617AbhGUAoy (ORCPT ); Tue, 20 Jul 2021 20:44:54 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:15043 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229854AbhGUAot (ORCPT ); Tue, 20 Jul 2021 20:44:49 -0400 Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4GTyVL414SzZr4q; Wed, 21 Jul 2021 09:22:02 +0800 (CST) Received: from dggpemm500002.china.huawei.com (7.185.36.229) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 21 Jul 2021 09:25:25 +0800 Received: from [10.174.179.5] (10.174.179.5) by dggpemm500002.china.huawei.com (7.185.36.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 21 Jul 2021 09:25:24 +0800 Subject: Re: [PATCH] ACPI / PPTT: get PPTT table in the first beginning To: Sudeep Holla CC: , , , , , , , References: <20210720112635.38565-1-wangxiongfeng2@huawei.com> <20210720133751.u6k6bdm7qco3gn65@bogus> From: Xiongfeng Wang Message-ID: <1c9112c0-8a3e-e82e-8c88-377e3d4e9e18@huawei.com> Date: Wed, 21 Jul 2021 09:25:23 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20210720133751.u6k6bdm7qco3gn65@bogus> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.5] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500002.china.huawei.com (7.185.36.229) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Hi Sudeep, On 2021/7/20 21:37, Sudeep Holla wrote: > On Tue, Jul 20, 2021 at 07:26:35PM +0800, Xiongfeng Wang wrote: >> When I added might_sleep() in down_timeout(), I got the following > > Sorry it is not clear if you are able to reproduce this issue without > any other modifications in the mainline kernel ? Without any modifications, the mainline kernel does not print the Calltrace. But the risk of sleeping in atomic context still exists. > >> Calltrace: >> >> [ 8.775671] BUG: sleeping function called from invalid context at kernel/locking/semaphore.c:160 >> [ 8.777070] in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid: 14, name: cpuhp/0 > >>>From this I guess you are adding sleep after raw_spin_lock_irqsave > in down_timeout(kernel/locking/semaphore.c). I add 'might_sleep()' which is used to check whether there are problems if I sleep here. It's not a real sleep. The Document for might_sleep is as below. /** * might_sleep - annotation for functions that can sleep * * this macro will print a stack trace if it is executed in an atomic * context (spinlock, irq-handler, ...). Additional sections where blocking is * not allowed can be annotated with non_block_start() and non_block_end() * pairs. * * This is a useful debugging help to be able to catch problems early and not * be bitten later when the calling function happens to sleep when it is not * supposed to. */ > >> >> It is because generic_exec_single() will disable local irq before >> calling _init_cache_level(). _init_cache_level() use acpi_get_table() to >> get the PPTT table, but this function could schedule out. >> >> To fix this issue, we use a static pointer to record the mapped PPTT >> table in the first beginning. Later, we use that pointer to reference >> the PPTT table in acpi_find_last_cache_level(). We also modify other >> functions in pptt.c to use the pointer to reference PPTT table. The main problem is that we called local_irq_save() in generic_exec_single(), and then we called down_timeout() in acpi_os_wait_semaphore(). down_timeout() could enter into sleep if failed to acquire the semaphore. There are risks of sleeping in irq disabled context. Thanks, Xiongfeng >> > > I don't follow this change at all. > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49911C07E9B for ; Wed, 21 Jul 2021 01:26:58 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0A65D60BD3 for ; Wed, 21 Jul 2021 01:26:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0A65D60BD3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:CC:To:Subject:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=8GhQe+dupkhZsddiwadBmJljEqhZTZxPsy8PpicqP+Y=; b=bxwzQjxbGAntUGDl5TYcMQdCRc BLdVS8E6HVr2ELrD08mhucU/oiG9ObRYCuzxCslfjixm+Ag50S06gWBzcIQOvfVei4bLI0Ciws7+7 8mTE+BCCUfQhOqm/zqkwATUtb17ZFjlFk1ibBh+YFQBRmIAkPRp2f/pq8tfZemvHkGRfVnZ8veX3x xicUtaLpLRz99bNEXaXyjQ+Rv7b+YM5BZOriKHYqXO91k0r1a+Fun4plwfY1Ks0wer9SLajEC/WU0 ePOjtSWgO6HdE633DRvlzPuGykb9QVFVhH1I8W6g/cl8LbY1lTayYLutHNvNDp0RHWLa70Qma+GhD CK9KKEzw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m60zN-00EEV1-Jt; Wed, 21 Jul 2021 01:25:33 +0000 Received: from szxga01-in.huawei.com ([45.249.212.187]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m60zJ-00EEUg-Af for linux-arm-kernel@lists.infradead.org; Wed, 21 Jul 2021 01:25:31 +0000 Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4GTyVL414SzZr4q; Wed, 21 Jul 2021 09:22:02 +0800 (CST) Received: from dggpemm500002.china.huawei.com (7.185.36.229) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 21 Jul 2021 09:25:25 +0800 Received: from [10.174.179.5] (10.174.179.5) by dggpemm500002.china.huawei.com (7.185.36.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 21 Jul 2021 09:25:24 +0800 Subject: Re: [PATCH] ACPI / PPTT: get PPTT table in the first beginning To: Sudeep Holla CC: , , , , , , , References: <20210720112635.38565-1-wangxiongfeng2@huawei.com> <20210720133751.u6k6bdm7qco3gn65@bogus> From: Xiongfeng Wang Message-ID: <1c9112c0-8a3e-e82e-8c88-377e3d4e9e18@huawei.com> Date: Wed, 21 Jul 2021 09:25:23 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20210720133751.u6k6bdm7qco3gn65@bogus> X-Originating-IP: [10.174.179.5] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500002.china.huawei.com (7.185.36.229) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210720_182529_607319_CB6BE589 X-CRM114-Status: GOOD ( 20.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Sudeep, On 2021/7/20 21:37, Sudeep Holla wrote: > On Tue, Jul 20, 2021 at 07:26:35PM +0800, Xiongfeng Wang wrote: >> When I added might_sleep() in down_timeout(), I got the following > > Sorry it is not clear if you are able to reproduce this issue without > any other modifications in the mainline kernel ? Without any modifications, the mainline kernel does not print the Calltrace. But the risk of sleeping in atomic context still exists. > >> Calltrace: >> >> [ 8.775671] BUG: sleeping function called from invalid context at kernel/locking/semaphore.c:160 >> [ 8.777070] in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid: 14, name: cpuhp/0 > >>>From this I guess you are adding sleep after raw_spin_lock_irqsave > in down_timeout(kernel/locking/semaphore.c). I add 'might_sleep()' which is used to check whether there are problems if I sleep here. It's not a real sleep. The Document for might_sleep is as below. /** * might_sleep - annotation for functions that can sleep * * this macro will print a stack trace if it is executed in an atomic * context (spinlock, irq-handler, ...). Additional sections where blocking is * not allowed can be annotated with non_block_start() and non_block_end() * pairs. * * This is a useful debugging help to be able to catch problems early and not * be bitten later when the calling function happens to sleep when it is not * supposed to. */ > >> >> It is because generic_exec_single() will disable local irq before >> calling _init_cache_level(). _init_cache_level() use acpi_get_table() to >> get the PPTT table, but this function could schedule out. >> >> To fix this issue, we use a static pointer to record the mapped PPTT >> table in the first beginning. Later, we use that pointer to reference >> the PPTT table in acpi_find_last_cache_level(). We also modify other >> functions in pptt.c to use the pointer to reference PPTT table. The main problem is that we called local_irq_save() in generic_exec_single(), and then we called down_timeout() in acpi_os_wait_semaphore(). down_timeout() could enter into sleep if failed to acquire the semaphore. There are risks of sleeping in irq disabled context. Thanks, Xiongfeng >> > > I don't follow this change at all. > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel