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 AB81DC021AA for ; Thu, 20 Feb 2025 02:40:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2D93F4401BD; Wed, 19 Feb 2025 21:40:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2B0504401AE; Wed, 19 Feb 2025 21:40:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 151E04401BD; Wed, 19 Feb 2025 21:40:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id EC6214401AE for ; Wed, 19 Feb 2025 21:40:42 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A71F112081E for ; Thu, 20 Feb 2025 02:40:42 +0000 (UTC) X-FDA: 83138769924.13.9DD3BDC Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf06.hostedemail.com (Postfix) with ESMTP id 027C4180007 for ; Thu, 20 Feb 2025 02:40:40 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jy6oHLYv; spf=pass (imf06.hostedemail.com: domain of mhiramat@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=mhiramat@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1740019241; 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=Yi2uS5oiLStNQ7ASk9a26Ojtm2znj3uY9s0WTd6viSA=; b=JKZwgbRtM55IhI0D0fOExOs0elW+kRz1uOX0RtQYZ3a4ZBQT3baWSaOEYy5ZtISGgpzmYN Z9g7UnGFZy2ivWdhcXfTt8qLqzZvqYueSFFN99NQ5aiZAm2HLMFIXlMsJZbCddV7WMRPjC RB8MRJbod9PnLP4GS0aVegSsfDjbupM= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=jy6oHLYv; spf=pass (imf06.hostedemail.com: domain of mhiramat@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=mhiramat@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1740019241; a=rsa-sha256; cv=none; b=yu8ZHhGfIB5jgNCtK8eSD+IKYPo5aN90439Fma+kvrC5N48JxbRrzo0RYtCyIypLGhZJRj o1YOx+JnOvc1VW0HWNrNwP6isxL8DIzoI0DJj2Chvwggx5iHiQJXEV72zJLluXQOvjy86B of7r+UzogOfaaAlN64Tz7Y+p4VDIzlw= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id D06DD6113E; Thu, 20 Feb 2025 02:40:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF0C6C4CED1; Thu, 20 Feb 2025 02:40:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740019240; bh=cZem6vk8RIlTJW54kI3MHj6xqDgsVXPXhU+70B7Qt2o=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=jy6oHLYvMtwLtyLJXKmfTufWlyI2tx2InFfzV/vBCExBM3Jk9BHkPNZ1fMP0WQnhL dzS82FcU8WpM2+VJX7pFZTzpQujWozF7BKqtwYkc9yvvOWyfWTfjOPzj8s0bNewGLz lGIXdIYh6oJ0hVVAxmJiTNBTztUJg/G+2hgPilwS6MhXOCe7ZI6G4ffy2N1vmkzjx3 S7CluCkVUzPTSQGpqpIKYrXSqahB7rL0+rA5vZRVgzvCP8t0VbBHtfIXs0gCetvVsh Ysm7/mbVwLPwKkXnAQ8aFeE7g0xR3m6uF/ADOawFDCgLovtzIRpCUQ/GFBQaSsLEar jjr0J5OjqGqhA== Date: Thu, 20 Feb 2025 11:40:36 +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: <20250220114036.e22e388402a00f7809a81dee@kernel.org> In-Reply-To: <20250219204153.65ed1f5e@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> <20250220075639.298616eb494248d390417977@kernel.org> <20250219204153.65ed1f5e@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-Rspam-User: X-Stat-Signature: m7dajtg4x1a1ftpb6pr9un8ddmn1ha5a X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 027C4180007 X-HE-Tag: 1740019240-211403 X-HE-Meta: U2FsdGVkX1+YvHVY7YJY5n++MJxvWjkhlVrJIJn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DM71PcwCd+1I+qI944/ULDInMnorDZ6bm0Tb751u5MQyhgMG3dOUXx+PP1cG8I3AWoNgqc0gu1mxdKPVqW2Kkaps4Mj2lhbqn+fN/TSFON1EvnRhM9C23HgjPCQh1JLg+8u+xpxS+Lr1B6qsOWV2cTsHu3zHYHEoWTAoupzQzr9vueWdVesRzG+4yEPxJZaaecHCkFX378Pl2Dg9FbsU19L2gblzHYcfZiYUj1V5VOYv7MHPmFD7lPq56+XoH5veCdvyPdj9if9XFddyndtc8fM6Ag/Zex2w/nuQ01yByW+l+/4KyEtHRge8K/qZgMhXTkvhEKoWLvOjdBwK4fr9+dY1ZGQ== 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 20:41:53 -0500 Steven Rostedt wrote: > On Wed, 19 Feb 2025 20:36:13 -0500 > Waiman Long wrote: > > > > >>>> 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. > > > Do we need to take it just for accessing owner, which is in an atomic? > > > > Right. I forgot it is an atomic_long_t. In that case, no lock should be > > needed. > > Now if we have a two fields to read: > > block_flags (for the type of lock) and blocked_on (for the lock) > > We need a way to synchronize the two. What happens if we read the type, and > the task wakes up and and then blocks on a different type of lock? Hmm, right. Since the blocked_on must be NULL before setting flag, if we can ensure the writing order so that blocked_flags is always updated before blocked_on, may it be safe? Or, (this may introduce more memory overhead) don't use union but use different blocked_on_mutex, blocked_on_rwsem, etc. Another idea is to make the owner offset same, like introducing struct common_lock { atomic_long_t owner; }; But the problem is that rt_mutex does not use atomic for storing the owner. (we can make it atomic using wrapper) Thank you, > > Then the lock read from blocked_on could be a different type of lock than > what is expected. > > -- Steve -- Masami Hiramatsu (Google)