Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C73B6C43381 for ; Thu, 21 Feb 2019 14:50:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 975BA20700 for ; Thu, 21 Feb 2019 14:50:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728751AbfBUOuS (ORCPT ); Thu, 21 Feb 2019 09:50:18 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:41984 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728700AbfBUOif (ORCPT ); Thu, 21 Feb 2019 09:38:35 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.91 #2 (Red Hat Linux)) id 1gwpUg-0008QB-2F for netdev@vger.kernel.org; Thu, 21 Feb 2019 14:38:34 +0000 Date: Thu, 21 Feb 2019 14:38:34 +0000 From: Al Viro To: netdev@vger.kernel.org Subject: Re: [RFC] coallocating struct socket and struct socket_wq Message-ID: <20190221143833.GB2217@ZenIV.linux.org.uk> References: <20190221081523.GZ2217@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190221081523.GZ2217@ZenIV.linux.org.uk> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Thu, Feb 21, 2019 at 08:15:23AM +0000, Al Viro wrote: > All instances of struct socket are embedded into some > bigger structure - most into struct socket_alloc (with struct inode > following struct socket), some into struct tun_file or struct > tap_queue. > > In the last two cases the corresponding struct socket_wq > (the one whose address goes into socket->wq) is in the same > containing structure, right after struct socket. > > In case of struct socket_alloc, we allocate struct > socket_wq separately and set socket->wq before anyone sees > either (in sock_alloc_inode()). In sock_destroy_inode() > they are both freed (struct sock_alloc immediately, > struct socket_wq - RCU-delayed). > > AFAICS, nothing ever reassigns socket->wq. Could we > simply embed struct socket_wq into struct socket? RCU delay > is not an issue - net/socket.c is non-modular, so call_rcu()-based > variant freeing both together is not horrible. sock_alloc_inode() > would be simplified, tun/tap uses would simply lose the separate > socket_wq members. > > The only problem I see here is ____cacheline_aligned_in_smp > we have on struct socket_wq. Could we simply make it the first > field in struct socket? Without lockdep they are reasonably small - > on amd64 socket_wq is 64 bytes, while the rest of struct socket is > 48 (and pointer to wq would obviously disappear). > > Or is there something subtle I'm missing here? Put it another way, what was the reason for "net: sock_def_readable() and friends RCU conversion" not to put RCU delay into freeing of struct socket itself? Separating the write-often fields from mostly read-only ones? I hadn't been able to find in archives the discussion from back in 2010, unfortunately ;-/