Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp128575rdb; Sun, 28 Jan 2024 17:34:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IE75cTqH9CFB4HNYJYCrMjFhktapO++SzxW5aS4Af17gBtVupaG4KeztLfS8pvO7JPe0O+u X-Received: by 2002:a17:902:d4cd:b0:1d8:88c4:148d with SMTP id o13-20020a170902d4cd00b001d888c4148dmr2772649plg.79.1706492069672; Sun, 28 Jan 2024 17:34:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706492069; cv=pass; d=google.com; s=arc-20160816; b=ewzYb1J4B6NEC/oOoAYsVw7H1g4k09a0aNWpd8gS3w2+8SQxk5nmxvqhuhYjXoO8SP mWgxZf5whGlfdqbJT6h0cLG/8/P2FKYZ8tpA/vWIcFKTthUJznzbm5SkVCpbExDnxOeQ njlGXSljJEIsIbjz/vPsbaZiHqj/LPhP2dl+PVTk5bPR4ynKzu7zllW76p6DcCmwILUI TAEJ2IR5dopGfZ+H0NJSUfXsRRwTGeeDNGDBtPLlt/PpSXoEhJ+oBu+MdE6FhRuIC2Rl 1scuOJqgFky+BtNorYnxpTppMlQbXnNWJirauXHcefwOwyKwFCE1TcoRVaPeRsuqMp/h R1zA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:dkim-signature:date; bh=qN1FxCPOJ5H4DfTAIjDzCCL68C4YSsHpS9Bz1bmn1k0=; fh=uqvSQzI9/8tfOBejfKYBzV9BcYjxeY5Kq8bk0PgZCPI=; b=wLKKgsdBipQUzpawsH7b1IT6Wo4EKEtMD9FBtiTyW8lLHjE6c+NkQNk1MaTWyIp6dp 2+t0p08CcITYW0+7Z0/o6+xXo2IlZum5ZIPmBrxlcPAOnBNB3/U3b2urZLRULaspIWTD lTwgIlLdc4SOT4WtBob07KbvecZo4H0c6YigkJ977CdzyNgf62dbsnmAlOwWE3dszKKN Smd8BZBzTTYjlR2D2By2usjVYcVnkWUxQL+4P2TnF+fQ2lDn+g8vdEd9S3JqeoZgUWI1 7BffMb9OLyKcXMWqqShnQR1sk2XIewO8Y7cmI9BViwYhNf6JCfjPSGL3FEE5gb0VtFKD 0tFg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=gWZNODXq; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-42064-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42064-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id ix11-20020a170902f80b00b001d8e4b74a22si714519plb.187.2024.01.28.17.34.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 17:34:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42064-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=gWZNODXq; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-42064-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42064-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 5479428269F for ; Mon, 29 Jan 2024 01:34:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A4B0ADF4E; Mon, 29 Jan 2024 01:34:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="gWZNODXq" Received: from out-184.mta0.migadu.com (out-184.mta0.migadu.com [91.218.175.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 08579F9EA for ; Mon, 29 Jan 2024 01:34:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.184 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706492055; cv=none; b=a9s2+xOzbY/xphg4CscfnWJJg8fBPLfBHiUS/DjU0ofY3Uan0aNIJLUDVJCNnFfz9/Bs3G+x1zUKlpvuu4HQjPfM8nc2NoziEDpFIC6rqo08aDsJ/cmGSr8YhELdGMz6vNYyvpZ1WDAxYEiTHH/06gAtPjrDev/zle7p/oI9bIY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706492055; c=relaxed/simple; bh=Sn3+afSObecsLwVspCGlRr2u/eqvfC8YAyQ9sYvfkw8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=s/abfyGIkRAdI3z5gbt2sfVXzIlP0azLEZ2n9dsdsQZd/USGP2+YuCoQTnz1spHtxxwhAvCAC1tjdy2GHFaPaWa96+ymLHuUJn8f85E1lhYBMp/pYNjw2pIj0A0mTmHQyfVs0FwrGRLRakASn4zvHItlVSJAIW7TW+8OJmE8k2o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=gWZNODXq; arc=none smtp.client-ip=91.218.175.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Date: Sun, 28 Jan 2024 20:34:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1706492051; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=qN1FxCPOJ5H4DfTAIjDzCCL68C4YSsHpS9Bz1bmn1k0=; b=gWZNODXqBwsyFdMkaap/3eI4ToaTkSkd2jmZCRqH68A4L/qscT0n11KdUHXc5vOwx69PoY zs+xKjY9vH52zOsb/4b+ZYKwL+JSWIDxGKNoASizHgo/AC7LnisSe6CHKVNBtCIyRE3JsO Gs/1pjjvKfQqQkF20NpSI01rtZ6LL4I= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Kuniyuki Iwashima Cc: boqun.feng@gmail.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, peterz@infradead.org Subject: Re: [PATCH 4/4] af_unix: convert to lock_cmp_fn Message-ID: References: <20240128205632.93670-1-kuniyu@amazon.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240128205632.93670-1-kuniyu@amazon.com> X-Migadu-Flow: FLOW_OUT On Sun, Jan 28, 2024 at 12:56:32PM -0800, Kuniyuki Iwashima wrote: > From: Kent Overstreet > Date: Sun, 28 Jan 2024 14:38:02 -0500 > > On Sun, Jan 28, 2024 at 12:28:38AM -0800, Kuniyuki Iwashima wrote: > > > From: Kent Overstreet > > > Date: Fri, 26 Jan 2024 21:08:31 -0500 > > > > Kill > > > > - unix_state_lock_nested > > > > - _nested usage for net->unx.table.locks[]. > > > > > > > > replace both with lock_set_cmp_fn_ptr_order(&u->lock). > > > > > > > > The lock ordering in sk_diag_dump_icons() looks suspicious; this may > > > > turn up a real issue. > > > > > > Yes, you cannot use lock_cmp_fn() for unix_state_lock_nested(). > > > > > > The lock order in sk_diag_dump_icons() is > > > > > > listening socket -> child socket in the listener's queue > > > > > > , and the inverse order never happens. ptr comparison does not make > > > sense in this case, and lockdep will complain about false positive. > > > > Is that a real lock ordering? Is this parent -> child relationship well > > defined? > > > > If it is, we should be able to write a lock_cmp_fn for it, as long as > > it's not some handwavy "this will never happen but _nested won't check > > for it" like I saw elsewhere in the net code... :) > > The problem would be there's no handy way to detect the relationship > except for iterating the queue again. > > ---8<--- > static int unix_state_lock_cmp_fn(const struct lockdep_map *_a, > const struct lockdep_map *_b) > { > const struct unix_sock *a = container_of(_a, struct unix_sock, lock.dep_map); > const struct unix_sock *b = container_of(_b, struct unix_sock, lock.dep_map); > > if (a->sk.sk_state == TCP_LISTEN && b->sk.sk_state == TCP_ESTABLISHED) { > /* check if b is a's cihld */ > } > > /* otherwise, ptr comparison here. */ > } > ---8<--- > > > This can be resolved by a patch like this, which is in my local tree > for another series. > > So, after posting the series, I can revisit this and write lock_cmp_fn > for u->lock. Sounds good! Please CC me when you do.