Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1683706ybz; Thu, 23 Apr 2020 03:50:27 -0700 (PDT) X-Google-Smtp-Source: APiQypIJwD/w+MJv5vJYlop7aw2PS30VA1elJOh9BBox6rrtW36uZ4Pksv0AaRsxxZsdxP8zWxEV X-Received: by 2002:a17:906:9482:: with SMTP id t2mr2012523ejx.241.1587639026963; Thu, 23 Apr 2020 03:50:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587639026; cv=none; d=google.com; s=arc-20160816; b=EMajGrM8pDgOXgaqaQZIV5GOrhCmoMR5h2C2S1Wz9OzrRHoekA9nDUWorp0paZy5m3 2N/74O84C99fDvOqdvkRqo6ySzUgl6CAhJ1MipEFFij5I0buKRnbG9QMJF1bg8lLVXe3 xQCdyr8i31Q7c/kHky7K6xMumRH/SKoHnjwleH6OvciTZ73qcB+4BZKEdIYwifIr+n7a mJ1PFlj9/rdwS2mbvbWD808LpR4POdkYlz1xCXiVj9Wy8bOy3/eFxd4sQmPZgmaTx6Hv DuBPaOP8RMMM3LtsqDae5R+3mbETHTYUN8u2bGQvfVecKoCHQOKVjKHHDLafco1YmTj7 C73g== 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; bh=Mu6b35axRwVrBUlXPprv21C840cEMuJ0lKIqslZzBig=; b=q7Q0zuu1qJpEh36XZ2FH9fPrp/nM/Bj8i2q04qkDC09DLmHD5uqRLCYsn3fuMfVUby tmfrEuSsJ2pXqQi2OVtP5f6Isnf4fs4xXgZp3EN3kHd9xAk21OKKUbAtqDi8yytHKeZN yWU+/evLBjI28ykLVseJimffPSOu7CkTdiwWg6eSXZxH7RGRFuIlPewm8Ex7pySNdDky 3SI6oOkiDINnUMxGICZZVQx5EZpdb7IrF6iUBNRafx5vcdfDWdcqjrY2EazW/31a4iMm vFHcit9yZsN54gXW5mZhWgjCPUmjw4J2Otqwp3QmJzQv4hOWOc16glmKYxW92ZqpYk4O DBNQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id me3si1047771ejb.250.2020.04.23.03.50.03; Thu, 23 Apr 2020 03:50:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727847AbgDWKsa (ORCPT + 99 others); Thu, 23 Apr 2020 06:48:30 -0400 Received: from mx2.suse.de ([195.135.220.15]:36930 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727815AbgDWKs3 (ORCPT ); Thu, 23 Apr 2020 06:48:29 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 82A42AC84; Thu, 23 Apr 2020 10:48:27 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 6E4CB1E1293; Thu, 23 Apr 2020 12:48:27 +0200 (CEST) Date: Thu, 23 Apr 2020 12:48:27 +0200 From: Jan Kara To: Amir Goldstein Cc: Joel Fernandes , linux-kernel , Jan Kara , linux-fsdevel Subject: Re: [RFC] fs: Use slab constructor to initialize conn objects in fsnotify Message-ID: <20200423104827.GD3737@quack2.suse.cz> References: <20200423044050.162093-1-joel@joelfernandes.org> <20200423044518.GA162422@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 23-04-20 08:24:23, Amir Goldstein wrote: > On Thu, Apr 23, 2020 at 7:45 AM Joel Fernandes wrote: > > > > On Thu, Apr 23, 2020 at 12:40:50AM -0400, Joel Fernandes (Google) wrote: > > > While reading the famous slab paper [1], I noticed that the conn->lock > > > spinlock and conn->list hlist in fsnotify code is being initialized > > > during every object allocation. This seems a good fit for the > > > constructor within the slab to take advantage of the slab design. Move > > > the initializtion to that. > > > > > > spin_lock_init(&conn->lock); > > > INIT_HLIST_HEAD(&conn->list); > > > > > > [1] https://pdfs.semanticscholar.org/1acc/3a14da69dd240f2fbc11d00e09610263bdbd.pdf > > > > > > > The commit message could be better. Just to clarify, doing it this way is > > more efficient because the object will only have its spinlock init and hlist > > init happen during object construction, not object allocation. > > > > This change may be correct, but completely unjustified IMO. > conn objects are very rarely allocated, from user syscall path only. > I see no reason to micro optimize this. > > Perhaps there is another justification to do this, but not efficiency. Thanks for the suggestion Joel but I agree with Amir here. In principle using constructor is correct however it puts initialization of object in two places which makes the code harder to follow and the allocation of connector does not happen frequently enough for optimizing out these two stores to matter in any tangible way. Honza -- Jan Kara SUSE Labs, CR