Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp969236pxb; Wed, 15 Sep 2021 18:21:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlDlguLaYMr3kZeEazx1KZPh/5IBVk3FZ4NGvzkNh1q2HTjintbYBaUoBcnYMTfjXjUxQ3 X-Received: by 2002:a05:6638:4122:: with SMTP id ay34mr2339335jab.131.1631755303215; Wed, 15 Sep 2021 18:21:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631755303; cv=none; d=google.com; s=arc-20160816; b=IrzXGTXn2YZy1ARcBkK6Tqu8HeVZl0xs7lgXgbphRYe+kiWTDMi04GmxRAIf7C8a1t +vzu8rDqEkSHbicMnbbES1vkDBua6lWtYMGozysd52fMkGZ4iX1TegxSXqfwpvWSEXDp 1G+l7Ew91RDkbiWzyfQZu2ta1M4ib6pYOtzHpreKrOYSUeFwRBD2TC/BtvhgRTK1ZJ+L NldoqlAQVS7OxRcau/M/YbwapDrogcbkUS5KPlRnsmHVKuK+rOV8HGRaZBAaCqd5uE0J +AK/86jSHojcTsYzUkViEkcU0d/tnPsVWNGRnVlm5Ge14CFFDEDqYS3K5bdcwrqEVmP0 M+rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:references:cc :to:from:subject; bh=Y3VvBlbUhu3YqvXbBjbA6d5CKuXewQIqX8FBJNqGnvg=; b=QbHmwbnBUd3CkMWmJR57GQR7YH7Ko5eYUzMtneecABETYSe88vIx3xT8Io4Nq8aIBO rEhfP/d9Rr3cjtIpa1an1tIYwn5deWJd/N9J7OpjP9/FfNoN8bn1cjit6R7MaVgtd3W+ WDIDftAEI+eDmb9JU7Kdn1HmuMzsh39jbBUY5ecD6rYDPznnrGfAoK25sGL+aPmfZJOC odoRPmSR9YPWNLLS8oQufTTnxET16232S8biwkUuHf1iFzEpZ/15AtppZCl8KnBOulQj xMMQieE7/vXoq/zfdjRfVTf+TXtFTPdqvN+IXKGgcJ8i5CXdaJ5EEhmv2iWHs7N20as0 6eZA== 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 h5si1334460jaa.119.2021.09.15.18.21.32; Wed, 15 Sep 2021 18:21:43 -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 S232520AbhIPBWO (ORCPT + 99 others); Wed, 15 Sep 2021 21:22:14 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:9881 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233637AbhIPBWL (ORCPT ); Wed, 15 Sep 2021 21:22:11 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4H8zgW1GwQz8yC3; Thu, 16 Sep 2021 09:16:23 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Thu, 16 Sep 2021 09:20:50 +0800 Received: from [10.174.177.243] (10.174.177.243) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Thu, 16 Sep 2021 09:20:49 +0800 Subject: Re: [PATCH v2 2/3] kfence: maximize allocation wait timeout duration From: Kefeng Wang To: Marco Elver , CC: , , , , , , , References: <20210421105132.3965998-1-elver@google.com> <20210421105132.3965998-3-elver@google.com> <6c0d5f40-5067-3a59-65fa-6977b6f70219@huawei.com> Message-ID: Date: Thu, 16 Sep 2021 09:20:49 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <6c0d5f40-5067-3a59-65fa-6977b6f70219@huawei.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Originating-IP: [10.174.177.243] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Marco, We found kfence_test will fails  on ARM64 with this patch with/without  CONFIG_DETECT_HUNG_TASK, Any thought ? On 2021/9/16 9:02, Kefeng Wang wrote: > > On 2021/4/21 18:51, Marco Elver wrote: >> The allocation wait timeout was initially added because of warnings due >> to CONFIG_DETECT_HUNG_TASK=y [1]. While the 1 sec timeout is sufficient >> to resolve the warnings (given the hung task timeout must be 1 sec or >> larger) it may cause unnecessary wake-ups if the system is idle. >> [1] >> https://lkml.kernel.org/r/CADYN=9J0DQhizAGB0-jz4HOBBh+05kMBXb4c0cXMS7Qi5NAJiw@mail.gmail.com >> >> Fix it by computing the timeout duration in terms of the current >> sysctl_hung_task_timeout_secs value. >> >> Signed-off-by: Marco Elver >> --- >>   mm/kfence/core.c | 12 +++++++++++- >>   1 file changed, 11 insertions(+), 1 deletion(-) >> >> diff --git a/mm/kfence/core.c b/mm/kfence/core.c >> index 235d726f88bc..9742649f3f88 100644 >> --- a/mm/kfence/core.c >> +++ b/mm/kfence/core.c >> @@ -20,6 +20,7 @@ >>   #include >>   #include >>   #include >> +#include >>   #include >>   #include >>   #include >> @@ -621,7 +622,16 @@ static void toggle_allocation_gate(struct >> work_struct *work) >>       /* Enable static key, and await allocation to happen. */ >>       static_branch_enable(&kfence_allocation_key); >>   -    wait_event_timeout(allocation_wait, >> atomic_read(&kfence_allocation_gate), HZ); >> +    if (sysctl_hung_task_timeout_secs) { >> +        /* >> +         * During low activity with no allocations we might wait a >> +         * while; let's avoid the hung task warning. >> +         */ >> +        wait_event_timeout(allocation_wait, >> atomic_read(&kfence_allocation_gate), >> +                   sysctl_hung_task_timeout_secs * HZ / 2); >> +    } else { >> +        wait_event(allocation_wait, >> atomic_read(&kfence_allocation_gate)); >> +    } >>         /* Disable static key and reset timer. */ >>       static_branch_disable(&kfence_allocation_key);