Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1121119pxj; Sat, 15 May 2021 04:37:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFI6Ik86e3KW02UNesTcejWPUaHoyGxxK1JWPyB2UeqJAx2fV+xj+xQhxMElwjSRzWDrJ2 X-Received: by 2002:a50:f418:: with SMTP id r24mr51423edm.175.1621078635609; Sat, 15 May 2021 04:37:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621078635; cv=none; d=google.com; s=arc-20160816; b=0oXLvgTvNrBhDxDoyxWwRLWJ3dYLKxS3YGyOMPEqMXzm/V1wU2N1eWxQXXPYXGL0Lz jaUUUyZbwNsFrHtz3uBhsYxzji1IpPBS+oPzyRGcA+fZAuF2RWIyTi4A0X780d+8h+z1 +PoPwdH4mE3N+P/0gHYwZzk/K8vmdhKAeGl/aMN4azArrOuJVnyOf1lmGNoQNCJk0DU6 4c8vd2h51MpCan3WlOA9wkLzRWd391uhSHkmNO5JwKYxwBk3WH3MvegknQ+MNir+1OCl EBqb/QnMpcT86X2k6+SpRZe0twa0c8sAKJVuhpIjkA2PP3DJby6/4RaE+GtHTX8cZ07B pyqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:cc:from :references:to:subject; bh=WPrBidRZkNAlaMX64skRNQa0FNpA9NxnDyPnbeG9T4I=; b=TY3dt2iBx3w4QeOL/c+UVrn9Hn0/HdDfRbg1665xlwnX81wAn43V22IgKN2UcZC+p2 UoB6Uiq5s5oxfF+8FLBrF/04gRDSPaP0GYL2vTS9SnX3+B8f6N3JI0zSc9vv7H5e3FVN z0q1ixDSbO5qJ5TeWFMlKTCSudsSocPNmLskrImf9FG7tQoUfOUe7AdxPKGHH73KS7dh rTWToJ1/J48rTF0Pf9iS7Hbyqy5d0ko0Xqubjh+Jyn4wyZtgLsLqB2tXwALg/jO+jgrb YbmuSoOP26e71jHmCLO8/PLrn0hsDVxCc4Mg8GxVji5eji9NKcBnhC0UgVSsA3L+UlBy R6yg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w17si8907235ejb.702.2021.05.15.04.36.51; Sat, 15 May 2021 04:37:15 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232951AbhEOIg2 (ORCPT + 99 others); Sat, 15 May 2021 04:36:28 -0400 Received: from www262.sakura.ne.jp ([202.181.97.72]:55424 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229701AbhEOIg0 (ORCPT ); Sat, 15 May 2021 04:36:26 -0400 Received: from fsav401.sakura.ne.jp (fsav401.sakura.ne.jp [133.242.250.100]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id 14F8XsEA017198; Sat, 15 May 2021 17:33:54 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav401.sakura.ne.jp (F-Secure/fsigk_smtp/550/fsav401.sakura.ne.jp); Sat, 15 May 2021 17:33:54 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/fsav401.sakura.ne.jp) Received: from [192.168.1.9] (M106072142033.v4.enabler.ne.jp [106.72.142.33]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id 14F8Xs83017195 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NO); Sat, 15 May 2021 17:33:54 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Subject: Re: [PATCH] kernel/hung_task: Report top CPU consumers To: zhouchuangao , Dmitry Vyukov References: <1620997011-106951-1-git-send-email-zhouchuangao@vivo.com> From: Tetsuo Handa Cc: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Andrew Morton , Kees Cook , Stephen Rothwell , "Guilherme G. Piccoli" , Michal Hocko , Lukas Bulwahn , Vlastimil Babka , linux-kernel@vger.kernel.org Message-ID: Date: Sat, 15 May 2021 17:33:50 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <1620997011-106951-1-git-send-email-zhouchuangao@vivo.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/05/14 21:56, zhouchuangao wrote: > 1. If the task did not get scheduled for more than 2 minutes, > report top 3(By default) CPU consumers. > > 2. By default, the CPU utilization of each process in one minute > is calculated. + all_cpu_usage(false); + show_top_cpu_consumers(false); + msleep(1000); + all_cpu_usage(true); + show_top_cpu_consumers(true); 1 second than 1 minute? Too short to determine top CPU consumers? > > 3. Add a new member last_cpu_time to task_struct to record the CPU > usage of the process at the beginning of the computation. Speak of syzbot testing, in many cases the cause of hung task is simply somebody else was consuming too much CPU resources. Therefore, without backtraces of top CPU consumer processes, I think it is not different from calling call_usermodehelper("/bin/sh", { "sh", "-c", "exec top -b -d 1 -n 1 > /dev/klog", NULL }, { NULL }, UMH_WAIT_PROC | UMH_KILLABLE); before panic(). Maybe a hook for executing some userspace commands with some timeout before panic() is more useful?