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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19559C021AA for ; Wed, 19 Feb 2025 23:09:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6C5DA6B00A7; Wed, 19 Feb 2025 18:09:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 64DE6280276; Wed, 19 Feb 2025 18:09:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4EE736B00AD; Wed, 19 Feb 2025 18:09:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 299AB6B00A7 for ; Wed, 19 Feb 2025 18:09:18 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id A3EBE1405D4 for ; Wed, 19 Feb 2025 23:09:17 +0000 (UTC) X-FDA: 83138237154.26.49C0187 Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf21.hostedemail.com (Postfix) with ESMTP id ECB091C0003 for ; Wed, 19 Feb 2025 23:09:15 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=XcCM8VYD; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf21.hostedemail.com: domain of mhiramat@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=mhiramat@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1740006556; a=rsa-sha256; cv=none; b=tzIFMqPtSHGU3O70lHTqsPBm+IzIKzW/gLd7Q/wehTgIE0lkDw7KvmQHtUIz7P4nCS1VWK ox9DuEF4seTZC4ricPzdKlL+9LFkQycm7QjaxaWOj6kU2AXtJRbbg2p9+0SZWrTl5XY9Z9 CDOcXCbVD4WRTEwaWV3V7Dc6updAngA= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=XcCM8VYD; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf21.hostedemail.com: domain of mhiramat@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=mhiramat@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1740006556; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=gqFkz7JHiLurameGkMNl/Fdt6b8DQbBoF87ZDrMinAI=; b=w+Kz2KayEnVnfSZwf3S1TDODh79TMA0kC/jDe94YN/lZnkxYKlTQh1ztR5SVk5OeYrE5np L42uro+aRdrQF4ucoulaKnsyl/ULcDrrLN3N/Fx8EBbaxofi+pql+M+DVmueUFDI5aOx1l LDZYGnI0v3B1vdD9RXeTSmL5kEZzjNk= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id CE72A6121C; Wed, 19 Feb 2025 23:09:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28399C4CED1; Wed, 19 Feb 2025 23:09:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740006555; bh=BHPfA7scL6aD43lk+kfJBreSZvIUi3wef4nJQKhdl0c=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=XcCM8VYDLETEgpvPPyUIEOzjM8w3ME4xDI7qQLjM1hqv9brigLN2obDgLIM3HYyK6 6nR4MJQxd1GvSt6l57Y4y+dgXd3EbIQZHLR6cKaA8Bh1PiAbBgdvGqaB/utblKRq1Z 1n4dChu/YZJQGYxagPSGi3+UNUYx09H5f3ALSMVK7WkT4UiWEclLXye5nnMzKh8f/j YXEalfhXjn6tH3lQxemYyj8sAqCsRgr2sOgMDWbIbRTd1gd911kCJWNFSs+oUNhunS zPeAQI2Q7uWFOSoy1XOg5HlJ57vMjkctopiaUn4Nl5KplzZgyM42bLCztfyTvEwbF/ a6GElo3wxD8/A== Date: Thu, 20 Feb 2025 08:09:08 +0900 From: Masami Hiramatsu (Google) To: Steven Rostedt Cc: Waiman Long , "Masami Hiramatsu (Google)" , Peter Zijlstra , Ingo Molnar , Will Deacon , Andrew Morton , Boqun Feng , Joel Granados , Anna Schumaker , Lance Yang , Kent Overstreet , Yongliang Gao , Tomasz Figa , Sergey Senozhatsky , linux-kernel@vger.kernel.org, Linux Memory Management List Subject: Re: [PATCH 1/2] hung_task: Show the blocker task if the task is hung on mutex Message-Id: <20250220080908.fc1494f0f7c611b48fbe0f8b@kernel.org> In-Reply-To: <20250219152435.35077ac3@gandalf.local.home> References: <173997003868.2137198.9462617208992136056.stgit@mhiramat.tok.corp.google.com> <173997004932.2137198.7959507113210521328.stgit@mhiramat.tok.corp.google.com> <20250219112308.5d905680@gandalf.local.home> <0fa9dd8e-2d83-487e-bfb1-1f5d20cd9fe6@redhat.com> <20250219152435.35077ac3@gandalf.local.home> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: ECB091C0003 X-Stat-Signature: swrcippd9wy69nfyxeyq9768mt4oycbx X-Rspam-User: X-HE-Tag: 1740006555-604293 X-HE-Meta: U2FsdGVkX1/ZljutTMpaxcKA9C7LXJ67f7i8sMKGmaguX0Fy6o4v/5zpToqBTOZ1goqk3jlciwDSo3kruSF+4EFOoP6yNG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A81lvaejjG/TmjrcysU31RQzLh7w3+oiQtdiWVxKnpJ81IyoafV+D5Kmybbr5UgB6Tq0ZNvKNJJ1tjukWnYJvkyiOezhov99XDZqDGBCOziEUocDOq/K0MldUjxO0CbPy2XWA/0Ce9WtH6p0NkqpBQ3aJgaXP75oLFZBl2gdpmu2fRcdR/U4NkqOjkbZQ1n2Kj1pacCL/6el2Xf+wSwPrejjA8yjtBpDd8rbZT9XPoGH4NUfxTzEB6g3kYtlxss0jwSGyXLXnW/loacohpfBhYLwfdUR3VVK4pv2A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Wed, 19 Feb 2025 15:24:35 -0500 Steven Rostedt wrote: > On Wed, 19 Feb 2025 15:18:57 -0500 > Waiman Long wrote: > > > It is tricky to access the mutex_waiter structure which is allocated > > from stack. So another way to work around this issue is to add a new > > blocked_on_mutex field in task_struct to directly point to relevant > > mutex. Yes, that increase the size of task_struct by 8 bytes, but it is > > a pretty large structure anyway. Using READ_ONCE/WRITE_ONCE() to access > > And it's been on my TODO list for some time to try to make that structure > smaller again :-/ > > > this field, we don't need to take lock, though taking the wait_lock may > > still be needed to examine other information inside the mutex. > > But perhaps if we add a new config option for this feature, we could just > add the lock that a task is blocked on before it goes to sleep and > reference that instead. That would be easier than trying to play games > getting the lock owner from the blocked_on field. So something like this? unsigned int block_flags; union { struct mutex *mutex; struct rwsem +rwsem; struct rtmutex *rtmutex; } blocked_on; enum { BLOCKED_ON_MUTEX; BLOCKED_ON_RWSEM; BLOCKED_ON_RTMUTEX; BLOCKED_ON_IO; } block_reason; For the safety, we may anyway lock the task anyway, but that is the same as stacktrace. Thank you, > > -- Steve -- Masami Hiramatsu (Google)