Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1842987ybz; Thu, 23 Apr 2020 07:01:10 -0700 (PDT) X-Google-Smtp-Source: APiQypIi/H/ELHOeovOq/iOZwltwa1Pi+jIsgVfgw1n3TKXV6t/GoglQIQ5svWQ81lDb0N1A3rXU X-Received: by 2002:aa7:d5d4:: with SMTP id d20mr2807624eds.369.1587650470459; Thu, 23 Apr 2020 07:01:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587650470; cv=none; d=google.com; s=arc-20160816; b=Ua7w+GCtmFjVYk06vNh+jccJTYnBJydFhOCe0rBMaBc2ylYwB3eJ59A+Cr/LwGizZQ ZxBIXhgtuPCFxnb9TasgOy7VRaLngPG0qXIYoP6s40T/Rbg08m9vYpnUKXSHe97Ab10f tHEvTeqtz3wzYtyJjvfnGwAiScHVIjWFhSRjhQF+rxcDzkuB49p2VkDRjmPEdAhc2TJN bGFRhQUf+dOIaVd0442Lt2eWHpfufB83NM/XXQsahF/b+XMvr2jJponwT09dFmWaWp+R sa37uwjjCdAB4M69jlm60pnSknZVCYMTo+Ue6Xj42GnH7DcAqECx+ZFLvWsGt2PNnzBd MVjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=tB+BVWMxib2gd9XqAz2QdvAOKuEQpc9FChbzR+SgxV4=; b=zf3bUEieSuxw5Pv/VzReOudaD2ywCDdw4R4ewZ9chdR7t83wb7efPA/NHm+7aCyHNt CQjE6mlUlEHBBIgQcZdl9xWv6XRLsdsztE8iPLNzxi5jsQqXmDDWF8W7iLQGKhvTuORv EgAnIlzPgnV1Ym+pMBm1sgk+pH7iwANkpRzgzXz4mDh6TrXDjmo73+tp4vSMvi7fKA8j CSkJ5erRtZTTcUrRIrp4FBF79Om2ehuy4NjSo6gvxRQO6QTTbFz2SE/mw5jFHXfqLCj5 Vg6v2KtkBOwbR7TOwKdTcC01KSlnboXN1PmqniAAmC6nO91cFq6n7Hnm5L0u8qlig6k5 LWIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=tbKgu6el; 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 dx8si1237089ejb.6.2020.04.23.07.00.44; Thu, 23 Apr 2020 07:01:10 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=tbKgu6el; 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 S1728046AbgDWLkK (ORCPT + 99 others); Thu, 23 Apr 2020 07:40:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727903AbgDWLkK (ORCPT ); Thu, 23 Apr 2020 07:40:10 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 039BDC035494; Thu, 23 Apr 2020 04:40:09 -0700 (PDT) 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; bh=tB+BVWMxib2gd9XqAz2QdvAOKuEQpc9FChbzR+SgxV4=; b=tbKgu6elYwtDE343Cpmt0XiJGp YBfbojKbLj9MhwhMUUK2urKoXUnNhgrOMDarNDfO6YA2yB65SSwjsKHPqDdVr9vm4XlcmSGQ8tGIp 6+vB+UqrpbQKsJSN1FU8awdV+mwaLz7mwcmVFAtyWoAIA0W6LA6Nc7l1bn8DxA7OPHB6w4sU2+OEs E2PnoNS1hbJx+RI2F7iAXFs9kxmluk94xuIjCWED41/z2Dwkjct59Gi90qX1ivsHBs1leveYOkJrD SzcZ7kRgpYF+2CQHNLPcn/4kjW7hItE3avfMSCU9tF7UCTQVc0gtr4RT6lAxr1KL6lcvh81ZStkYy ahRXi2vg==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jRaDA-0002U1-Dr; Thu, 23 Apr 2020 11:40:08 +0000 Date: Thu, 23 Apr 2020 04:40:08 -0700 From: Matthew Wilcox To: "Joel Fernandes (Google)" Cc: linux-kernel@vger.kernel.org, Amir Goldstein , Jan Kara , linux-fsdevel@vger.kernel.org Subject: Re: [RFC] fs: Use slab constructor to initialize conn objects in fsnotify Message-ID: <20200423114008.GB13910@bombadil.infradead.org> References: <20200423044050.162093-1-joel@joelfernandes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200423044050.162093-1-joel@joelfernandes.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. The slab paper was written a number of years ago when CPU caches were not as they are today. With this patch, every time you allocate a new page, we dirty the entire page, and then the dirty cachelines will gradually fall out of cache as the other objects on the page are not used immediately. Then, when we actually use one of the objects on the page, we bring those cachelines back in and dirty them again by initialising 'type' and 'obj'. The two stores to initialise lock and list are almost free when done in fsnotify_attach_connector_to_object(), but are costly when done in a slab constructor. There are very few places where a slab constructor is justified with a modern CPU. We've considered removing the functionality before. > @@ -479,8 +479,6 @@ static int fsnotify_attach_connector_to_object(fsnotify_connp_t *connp, > conn = kmem_cache_alloc(fsnotify_mark_connector_cachep, GFP_KERNEL); > if (!conn) > return -ENOMEM; > - spin_lock_init(&conn->lock); > - INIT_HLIST_HEAD(&conn->list); > conn->type = type; > conn->obj = connp; > /* Cache fsid of filesystem containing the object */ > -- > 2.26.1.301.g55bc3eb7cb9-goog