Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5063121pxv; Tue, 20 Jul 2021 18:26:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx61HcR8O7s3CPcwtQpeW8qw6/zygFor8SfsJuFfFpm+WkC1DYPFpgjWX3/nRwJvhfnwriz X-Received: by 2002:a92:c54d:: with SMTP id a13mr9997268ilj.74.1626830807528; Tue, 20 Jul 2021 18:26:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626830807; cv=none; d=google.com; s=arc-20160816; b=Pw1T3hIDZrfNLqRbhFtA6OrLGjaFtYY2QpjXNWQ8FVnjEW3LVdzBiK95lN52XRnh6u JuWy6V/6wbvRjVbonttuseyRgKuIe4C+1UAsgI5OIyP/85Sx8Vem2LXn8gg5pzGZA+fl uRR6WI+xy4R7q3iwz3/43m2iT5zE+cmjkLhmwkTipPZ6mPG2sdjHi7h2E4MzYO1IcB8k 9J6YZvym8mSvhjLKycg3PhkMJn0YQ5J0Aqu2mUuqgsc8r/Y26+xev2aLmaccPUHvwBXs 41w2VxVI2PTb3BDcJg5fobpM61Bauk3iAJ5vaf6tYuVcnq8ECh019gg7e/43RPvwKHYI mAug== 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=KOYXqXTu8T1o/90BN6u5ZcwU5LyPgphNXQd3pBOTlA8=; b=cIr+3TsqSl/Q5Kmawn4teLWLmRWNQW5sA2xD4aKZ0iSeWx9HXO7tci+nHFda2Zo0W5 vlYdIfCA20ZyiLmwvKoDuz68mqeH2RRYTO4VAF9lc3b4VYrvESzMZSh5lxp+3LPWevic 7DRAHRmtu7/IMTJIHErtt6v6mtCkHYO/LtQwVqSCTrT6olCKyjAMmQJv2x4a+gyD2SI2 7Qgf2gQCnAIIruDxkLpE6jwvRbol/zBm7sZSlf4E5ePwPBjIZWavrqaP6SH45BvtWVXL RjGTvvEEIjmGNdjqyfd+C+Z3ca9MtUX/D5F8/77wJV3if4YWlQ5nSPNCyAegNyOQ4nYK Qvjg== 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 v8si15481198jas.68.2021.07.20.18.26.34; Tue, 20 Jul 2021 18:26:47 -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 S229668AbhGUAoz (ORCPT + 99 others); Tue, 20 Jul 2021 20:44:55 -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-kernel@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. >