Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1016487imm; Wed, 1 Aug 2018 08:52:56 -0700 (PDT) X-Google-Smtp-Source: AAOMgpePRAggEwSubMIz2q7FMk0uhvc7DxTm5Mhh4MSYZ6GwYtPC6Ttc3kkCX9V4KCapKbGkBoBA X-Received: by 2002:a65:5a49:: with SMTP id z9-v6mr25359747pgs.244.1533138776646; Wed, 01 Aug 2018 08:52:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533138776; cv=none; d=google.com; s=arc-20160816; b=kbL5ix9qzT6c6r/hok0fcwh/lwDnADI3BmKIxG55JCxQnFEPXkyHB4bsqjG0Z5FaQz kHeJmA/Q915+3TxpfP6K1F+2nIrY9T4kYiGK3/kt9Jl/Cn3zRWtmaw5TPiFC8O3XmdnS 15DwxIALrCoN6LziX0+tOqPWAL1ZgmAwVV3DZoHDfg15iIg9/sduEalHv+6nlsTlhiun dpDC8HtGh9Tb5pm7gik7uKUC9aaaFT7ygDwHB4AGp84/gpQgp5zpqmIpATJM94zHr7CG v2vo81mNlUfBqEy9MdhWwAIQSG8iqd4x+8pDz36tcq1CEJUK39jgVYdoWs4W147K5oFt izBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=JGGGUPL8y+Sg9MFwW8cY9lJ3vvwCFtGeyT8ocGR/Lto=; b=w+NDpfSvUo6l8V9hzV/VlWArrajjRCj0rlMSLf6zn7Yduwq0S8/H8kbBmXjQnDnsRH CHiDRy0wN5IGU+DPz5eyn+zbb8Zw91p51dYycE0iIAFNxGGywKKL27Cy6wLQRjho43d0 WQ2vrQSV63ZQ9JkvE/8VLSZR9uBmBwWKBwTbGlkDLLlbFa+xcYbQ0//FE1k4gMmTrmAC 23a4NRwSTBDgfZIJsIJ/Q239zlLnW5shqDdgAZS0tMclsYycU0rHpBsAshetzNCUgMMh 4abTbLcab7sOH4oM8yCazyesBndIFysOeP4Vv4/EZ9oNRx8CokV6isT4C9S0Y1mjsjV4 mNBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="O/FY0+ar"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b76-v6si17147830pfl.223.2018.08.01.08.52.41; Wed, 01 Aug 2018 08:52:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="O/FY0+ar"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389907AbeHARiN (ORCPT + 99 others); Wed, 1 Aug 2018 13:38:13 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:56254 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389557AbeHARiM (ORCPT ); Wed, 1 Aug 2018 13:38:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=JGGGUPL8y+Sg9MFwW8cY9lJ3vvwCFtGeyT8ocGR/Lto=; b=O/FY0+arLoN3yvgTDaQdaP11A sFtp5jmbphrcnIRsmYkDI6jzby+x3hdhhGH3Ej6fnPHKWn7LDNSAILFeGxDnyf4U/5c9pbbsXbsdx nDfAIa7IkUvZkijysDA0qV/s1PLw0ypgiXnmO1KDQpyR6c+Nm5OuyiTjH/meSWVYUkR+XBCouLEaj EyWd3E80RP3YZd75oTyxmuRBQqCWjdwPRKt5lDbOd6qWUOS4lqmkSfAO9kV/ndWWGjUZM/kvOKUW4 AJxw6be/Xd8UB4g7HoVlVPBHIUpOqakiXSHWwvAcTONZp83sKS2ay+yxDO6bPxhI42ERKRVlbTp3/ DZcU9JLhg==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fktPU-0004Ho-UI; Wed, 01 Aug 2018 15:51:36 +0000 Date: Wed, 1 Aug 2018 08:51:36 -0700 From: Matthew Wilcox To: Eric Dumazet Cc: Christoph Lameter , Dmitry Vyukov , Eric Dumazet , Andrey Ryabinin , Linus Torvalds , Theodore Ts'o , jack@suse.com, linux-ext4@vger.kernel.org, Greg Kroah-Hartman , Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , David Miller , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev , Gerrit Renker , dccp@vger.kernel.org, jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com, rodrigo.vivi@intel.com, airlied@linux.ie, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Alexey Kuznetsov , Hideaki YOSHIFUJI , Ursula Braun , linux-s390@vger.kernel.org, LKML , Andrew Morton , linux-mm , Andrey Konovalov , linux-fsdevel@vger.kernel.org Subject: Misuse of constructors Message-ID: <20180801155136.GB4039@bombadil.infradead.org> References: <01000164f169bc6b-c73a8353-d7d9-47ec-a782-90aadcb86bfb-000000@email.amazonses.com> <30ee6c72-dc90-275a-8e23-54221f393cb0@virtuozzo.com> <01000164f60f3f12-b1253c6e-ee57-49fc-aed8-0944ab4fd7a2-000000@email.amazonses.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 01, 2018 at 08:37:07AM -0700, Eric Dumazet wrote: > The idea of having a ctor() would only be a win if all the fields that > can be initialized in the ctor are contiguous and fill an integral > number of cache lines. Let's state it more generally: Having a ctor is only a win if it allows the user to avoid reading or writing a significant number of cachelines. For example, the radix tree node occupies nine cachelines (576 bytes). The typical user will touch two of those cacheliens (the header and the cacheline which contains the slot of interest). That's seven cachelines which don't even need to be read, let alone written. I think filesystems are particularly prone to this antipattern of initialising some of their inode with a ctor and the remainder at alloc_inode() time (compare the locations of the struct members touched by inode_init_always() and inode_init_once()).