From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 16AE64C65 for ; Sat, 13 Apr 2024 02:05:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712973924; cv=none; b=Aa9td+UgIOMjY23fwtM5pt8ilwvX82yx9pdyc2ygC+XMAvtlyauSYyyju5/lmKACoYY6WL+VMpuqCMnksYb6lnlNWTGkINEs1KV1afI5pQbmAgUHV5xKwm9s9sQl9wWZi1n0HDhC2R5Usfb8eLWfyNkp8DAcUZ5R6xHELkzYNA0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712973924; c=relaxed/simple; bh=JyY037Ca3pzq/a9cKQIyCZPtAKZQJeoY1D+t5tAioM8=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=B1wRjoeBaI9ND3YyRITac6/s0eLWPNL1AxaMEgB31evO5Pp7HuirIPoasK/aSoKDmG2GjjoXiZ9hXpzr4HL1YB45rmjYgL9xTPCLzX8e299xFRpSTbjUY7h4OVVUDaDO/fYqO5pUHH7FYyKLI50m6NW2xCEut3NmBN6BPuVy5po= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pKNsB5G2; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pKNsB5G2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43F44C113CC; Sat, 13 Apr 2024 02:05:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712973923; bh=JyY037Ca3pzq/a9cKQIyCZPtAKZQJeoY1D+t5tAioM8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=pKNsB5G2yPySFIT2rqkyjoBRCYD6XS4aEVusGgyZel4+gdz1SM3nOC4fsqviwm+4g f7GSxA85cY0mkonNQKhi6+JAFhUfaA1qB1TnmzOd05abHcqzylSoJ81iJgBxcqVM0A V7swLO4gWxK82cQ9kdFwMKQko7o8tj1Orubi5xJHLUDbjvH8sWn9Xx6FDsTWzFuIIt XQWQMXlvBJgAx5ouJEzSyA7yWwmqUjkIyM6cue3JbGqw+FlQLn1gCQgdS8u2Pcsm8A kg0IdDGPqy4g0ZsE6htBOFsRhPYmiA7XInTwavwFb45EIacjbEgPJ296LABo7v2WPS dne3EH3IS+Rfg== Date: Fri, 12 Apr 2024 19:05:22 -0700 From: Jakub Kicinski To: Kuniyuki Iwashima Cc: "David S. Miller" , Eric Dumazet , Paolo Abeni , Kuniyuki Iwashima , , kernel test robot Subject: Re: [PATCH v1 net-next] af_unix: Try not to hold unix_gc_lock during accept(). Message-ID: <20240412190522.3a157f00@kernel.org> In-Reply-To: <20240410201929.34716-1-kuniyu@amazon.com> References: <20240410201929.34716-1-kuniyu@amazon.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 10 Apr 2024 13:19:29 -0700 Kuniyuki Iwashima wrote: > void unix_update_edges(struct unix_sock *receiver) > { > - spin_lock(&unix_gc_lock); > - unix_update_graph(unix_sk(receiver->listener)->vertex); > + /* nr_unix_fds is only updated under unix_state_lock(). > + * If it's 0 here, the embryo socket is not part of the > + * inflight graph, and GC will not see it. > + */ > + bool need_lock = !!receiver->scm_stat.nr_unix_fds; > + > + if (need_lock) { > + spin_lock(&unix_gc_lock); > + unix_update_graph(unix_sk(receiver->listener)->vertex); > + } > + > receiver->listener = NULL; > - spin_unlock(&unix_gc_lock); > + > + if (need_lock) > + spin_unlock(&unix_gc_lock); > } Are you planning to add more code here? I feel like the sharing of a single line is outweighted by the conditionals.. I mean: /* ... */ if (!receiver->scm_stat.nr_unix_fd) { receiver->listener = NULL; } else { spin_lock(&unix_gc_lock); unix_update_graph(unix_sk(receiver->listener)->vertex); receiver->listener = NULL; spin_unlock(&unix_gc_lock); } no?