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 BC215C3ABC3 for ; Mon, 12 May 2025 15:02:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7040A6B0161; Mon, 12 May 2025 11:02:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B2266B0162; Mon, 12 May 2025 11:02:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 579866B0163; Mon, 12 May 2025 11:02:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 389A36B0161 for ; Mon, 12 May 2025 11:02:00 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 8769116150E for ; Mon, 12 May 2025 15:02:00 +0000 (UTC) X-FDA: 83434570800.12.393C224 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf21.hostedemail.com (Postfix) with ESMTP id A1A571C0016 for ; Mon, 12 May 2025 15:01:57 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=GP3ljgIv; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=mWg1lQ6V; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=GP3ljgIv; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=mWg1lQ6V; dmarc=none; spf=pass (imf21.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1747062118; 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=z+jY5KN8CzrMEF4lIZPKa3xcJF27rsMzAOY3MhSK37s=; b=RQgNBhy4WaA5o+Y7CJyqFjqAd0js7qL5IIw6jojYtfWXKxE4VptmbWv9HbfE3V2J6FSv/i Q/ew2zm5Fy4yO17Xe+3Jm7AV995aR/GngZ6sdLVlWEOSag8JTPBRLVN1lOsHFa7N2RPRjy mGKu5YVJeDm86GuHsgDeVC4h8SyJuBU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1747062118; a=rsa-sha256; cv=none; b=l5Z3BYt01e+2luO0qsRxKKXRtJXP7dpLfH15ra1hfKaMybfMLqC+Mqm8K6P2xnF/wM6/D4 9cTAe8HlJ6nvzaixqc/W2ITO9jWAjDOqbQ5yE1wm8mmZKkf5vYfHYvxC9UDTli3DxTyWeR kruq2pjl1pYuTsiOhOL5Mq71wxVi93U= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=GP3ljgIv; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=mWg1lQ6V; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=GP3ljgIv; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=mWg1lQ6V; dmarc=none; spf=pass (imf21.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=vbabka@suse.cz Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 04F7F2120E; Mon, 12 May 2025 15:01:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1747062116; h=from:from:reply-to: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; bh=z+jY5KN8CzrMEF4lIZPKa3xcJF27rsMzAOY3MhSK37s=; b=GP3ljgIvQS79LkmAxmgp1dX3TqskOm2yM8hFImuRtN+kXxtB6eb3dmaXnWNNgQy5AgcKW+ +pXRoh0mgPjFT2zAeBoJdcuAlYkHwCqVr3wZDXFeVhzPFpmV5xoe8gZj/Beyb6HFPZAHV1 27r0sQy/XL/6FFmjt+d4HMkW1AFM0co= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1747062116; h=from:from:reply-to: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; bh=z+jY5KN8CzrMEF4lIZPKa3xcJF27rsMzAOY3MhSK37s=; b=mWg1lQ6VnhDs+sYrgbWP1S77sAw5AtOHwP61Dn+IVzLvV1OPvHeUrzSRpP8pijkBs683Xc GwYO7YRGWN3H/uDw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1747062116; h=from:from:reply-to: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; bh=z+jY5KN8CzrMEF4lIZPKa3xcJF27rsMzAOY3MhSK37s=; b=GP3ljgIvQS79LkmAxmgp1dX3TqskOm2yM8hFImuRtN+kXxtB6eb3dmaXnWNNgQy5AgcKW+ +pXRoh0mgPjFT2zAeBoJdcuAlYkHwCqVr3wZDXFeVhzPFpmV5xoe8gZj/Beyb6HFPZAHV1 27r0sQy/XL/6FFmjt+d4HMkW1AFM0co= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1747062116; h=from:from:reply-to: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; bh=z+jY5KN8CzrMEF4lIZPKa3xcJF27rsMzAOY3MhSK37s=; b=mWg1lQ6VnhDs+sYrgbWP1S77sAw5AtOHwP61Dn+IVzLvV1OPvHeUrzSRpP8pijkBs683Xc GwYO7YRGWN3H/uDw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id DE2FF137D2; Mon, 12 May 2025 15:01:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 6u3uNWMNImiHSAAAD6G6ig (envelope-from ); Mon, 12 May 2025 15:01:55 +0000 Message-ID: <1c9bbd31-10f1-41b6-b2b9-745ab4e9e2ad@suse.cz> Date: Mon, 12 May 2025 17:01:55 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 3/6] locking/local_lock: Introduce local_lock_is_locked(). Content-Language: en-US To: Sebastian Andrzej Siewior , Alexei Starovoitov Cc: bpf@vger.kernel.org, linux-mm@kvack.org, harry.yoo@oracle.com, shakeel.butt@linux.dev, mhocko@suse.com, andrii@kernel.org, memxor@gmail.com, akpm@linux-foundation.org, peterz@infradead.org, rostedt@goodmis.org, hannes@cmpxchg.org, willy@infradead.org References: <20250501032718.65476-1-alexei.starovoitov@gmail.com> <20250501032718.65476-4-alexei.starovoitov@gmail.com> <20250512145613.eD3DUEa8@linutronix.de> From: Vlastimil Babka In-Reply-To: <20250512145613.eD3DUEa8@linutronix.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Action: no action X-Stat-Signature: wj3bh6egwge4bj17bek943g4z19djqqr X-Rspam-User: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: A1A571C0016 X-HE-Tag: 1747062117-158332 X-HE-Meta: U2FsdGVkX1/9s0TA8g7NyJ2JTQRAJUizR5Po3ecRbWIr+vwaKU4znDm3hbaB3SRPyqEh26Luo9LOcAuNppdrEm76FGHdoxv0V8oqjoFZj7RQjIOQlHO7VW/+zt5Idkp7SL3WWnR2+PGm9o576AOkEVXKUnvGFwZbsQ5pC6swDdoOsbmsF4DsErLxMFXrj9eVXNgHENyeiDdsv1QSMIJx26M/H4uBE3gt/disuJ1xzgBQqkLO+mg1HfXfSjFW79kQX6zHncn0+UM5fB8T2O4GmVrhFBM4XNtp+Z8doqp/vqz7fdgt3UzI0r+OvemJKGW1Jh4Y4pUmgZjbR+CJWYvwQ/tdInFCHkoYoHG37WEBiYb1zxvimu79TNN3f1xasabBuE7ju/gK9uPXerRP9sypKa1crJZMdlNzBQXsRQrN/iuARqzcDQOP1d1RsWYTCOokLCRpyOZxqLvh1QOH0rk/9UAkjUlQlJ5Q0EEhQNmL48Wch64HxT9EbOk/JOV6eZ1lJVcEUB4YIHHzfkO5bYojfRIxChJyqPsK48xe5VOp6Dtn4ZZ5oLmhwrL/5K1vw2m0Z/NGjdSlz8kAfCBwQNCcCcWLofVhB1N2FNjtpCkUtrMC18wHvEBoa1/bHQcZDCDu6w6pKYeF3HMNUYKbHljn0RiVsHWu3VmoJ3JV1w7uAeDCz0CTb4xqk66B+mu+MbuDK1WTxY5D+YBY1aUDGzcpLPKA/1ix+nXVVOPDG6z//CTGr1gC6RvvufvWx4/pholdlQOLkgJzoYJD/ASq7OyQOJaoaezjoOYCgMcCs7TgTvFPu4oP7n/oyxCuxTRQUWwf0CBb5xkbcYlh7AvHUOaB3/RDzDfm4W0qqngNcJiur3SlAwfTi9kz6rFd6ehWcOKMrmSlhNaaJNtzYy09rMhv8vRPPoyDJL52h2mTqpDJBjRQWRSKxBEgsEfOEJ2CIp6pFQg0T7n5z/2eOe62qLz wBgsCG2p HezKyd26RtfPwlOYueWlHEYnAb8YkWSVC9aHUCnHxmpZWoSdIR3zPqOa7sLx03JM33HRMj1IC+h5aRAsXr0g8bsj3XJxI87dlNyaW5k66Ziplz18aPSm31/PCJTPCqNwgOGQE9fJZFIgxervB6D9WwzIvKWJQ44I12mYww7r7uDP/yaJH5Pxym9IUrrImr+3XdjAhO2whG9z1/NhyyGRWz78GEe3eKS08l5DDcJ2cnmaTK5NEDE6SOp8n+PtcDpHMw5nbx5+PKFGiXzIxKBOpyaovP6cGf1ptHyaCytfUtPXPLFh+STmOdnH4tKlf/Yas+HulLw6AdxZ+Ew2wsCWtj9LUDQ6oGH9iDVRAxoQulmnjRrblnRxbAZiki/CKgOFxlnLt5rd/WjgKWl+Ol0/V/4eXIs30Oq3KgOKJe97hCxKCxhs4yCoM6Ev1EbjTMfZM+dXF922AouC+bVQ= 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 5/12/25 16:56, Sebastian Andrzej Siewior wrote: > On 2025-04-30 20:27:15 [-0700], Alexei Starovoitov wrote: >> --- a/include/linux/local_lock_internal.h >> +++ b/include/linux/local_lock_internal.h >> @@ -285,4 +288,9 @@ do { \ >> __local_trylock(lock); \ >> }) >> >> +/* migration must be disabled before calling __local_lock_is_locked */ >> +#include "../../kernel/locking/rtmutex_common.h" >> +#define __local_lock_is_locked(__lock) \ >> + (rt_mutex_owner(&this_cpu_ptr(__lock)->lock) == current) > > So I've been looking if we really need rt_mutex_owner() or if > rt_mutex_base_is_locked() could do the job. Judging from the slub-free > case, the rt_mutex_base_is_locked() would be just fine. The alloc case > on the other hand probably not so much. On the other hand since we don't > accept allocations from hardirq or NMI the "caller == owner" case should > never be observed. Unless buggy & debugging and this should then also be > observed by lockdep. Right? AFAIU my same line of thought was debunked by Alexei here: https://lore.kernel.org/all/CAADnVQLO9YX2_0wEZshHbwXoJY2-wv3OgVGvN-hgf6mK0_ipxw@mail.gmail.com/ e.g. you could have the lock and then due to kprobe or tracing in the slab allocator code re-enter it. > If there is another case where recursion can be observed and need to be > addressed I would prefer to move the function (+define) to > include/linux/rtmutex.h. instead of doing this "../../ include". > >> #endif /* CONFIG_PREEMPT_RT */ > > Sebastian