Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2871538pxb; Tue, 21 Sep 2021 09:24:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVgXFS5HR+YUnkoc+xJSn4Jju1Xqd3BJEpGlL0A9TYUED8W2NAtE+he6JWhhBRcWXtFB1k X-Received: by 2002:a92:c248:: with SMTP id k8mr20422380ilo.52.1632241478437; Tue, 21 Sep 2021 09:24:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632241478; cv=none; d=google.com; s=arc-20160816; b=AEBUfJJWfItQsqD+5MC+MO49nJztUMABaOKx+kwMNMwh6gvxJEbScrHRVgvkadlMw/ EVzVE1RAaTo4B8unipq/V1y0kNmxsujmpERoSHntSfFLJ+zzUvpXeqEiRiYQQcEG9301 LVNkAysgCe0RT2JCejxQd5v3f/ITfdHyFCTxqpCjLtO1oGQ5YKO9sjjzZITMPU8j4kY8 /D7OaVYyNIzVheM/aYKuq+hQrJs6aSHLvbjFKqyPjJ6lISF9Rh6BmFEyXs7Ac7V6nKp7 4XYHQ0wWeQpRwmy1mhTKlvlOQpEQx4XymfwsEMMKczIo8Z9Dsne5F1wwLkUQEspPXrfC Z5eA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=9/YVI0YfDL2V4vcHeVmIRPEOUQt1TJerDuRFTwKveSE=; b=YfxHvOQ8+FgxP2CdRuw6n+c8ij/psTQd5LYV7nhW0Es+NOPgyRLaAi0MjvNLfoY9w4 rS9hpe/2heNMDYol9s3rasnpl7qMlYBxEWsDQGXEkK5n+YEdr49c8nqSaLjbkeFMENX/ H80FWsvS/0YOuo8ILpm7TvQHlSP1wkUCT56PAtBDpx0HDLrnOuEu9FwdbzYmJzjJRxFR DOtlTGsusCY0wGl2MDcHyhpEYiaf5+Te/f7G5eAH653q9h+zeGLa5oI3Eejl1wWI8Dnd cIgVjhAFvKPmvn6Lc720woufGmYi6n04a0Gvyk69cjKFAkLFJMJn4OSBFN0J8X4Sd4ZJ KQAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b="AVS/5IVt"; 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 f8si6366590ilu.129.2021.09.21.09.24.24; Tue, 21 Sep 2021 09:24:38 -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=pass header.i=@infradead.org header.s=casper.20170209 header.b="AVS/5IVt"; 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 S233699AbhIUQXi (ORCPT + 99 others); Tue, 21 Sep 2021 12:23:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231297AbhIUQXh (ORCPT ); Tue, 21 Sep 2021 12:23:37 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6EF0C061574; Tue, 21 Sep 2021 09:22:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=9/YVI0YfDL2V4vcHeVmIRPEOUQt1TJerDuRFTwKveSE=; b=AVS/5IVt0MCm2i6EdN5eEegLQo y4M1Ea3I0Vii+1zNHmWuCVaMY72NHXxis7XkhIug7SJCSHUJk6gUwX7A8DwjBMrKyoJg7iAWec7OC HV8Bc4tHIM5Of2fmfhIQZarEfk/f5KLKmSpSHBZMvTO76TzWlHhIGnj6i9Auoi4vhN/NizQVQWbuu NFnOYCQZOkgB4KEHzmWWgP/FY3zHJ2D1EBKX3oTEh2sojbj7wjNEpernXSyfyw6Bsjk5hqJXdBAiZ J8zqJb6fNxwgSxO/qnWezM10SOUMPPTyYKldhdco+ZnmPf69EFrzyWdoIzYGrL7WRGt88kWkIMxb0 MCgeNkCw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mSiS6-003xNv-8T; Tue, 21 Sep 2021 16:18:00 +0000 Date: Tue, 21 Sep 2021 17:17:02 +0100 From: Matthew Wilcox To: Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: linux-mm@kvack.org, Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , linux-kernel@vger.kernel.org, Jens Axboe , John Garry , linux-block@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [RFC v2 PATCH] mm, sl[au]b: Introduce lockless cache Message-ID: References: <20210920154816.31832-1-42.hyeyoo@gmail.com> <20210921154239.GA5092@kvm.asia-northeast3-a.c.our-ratio-313919.internal> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210921154239.GA5092@kvm.asia-northeast3-a.c.our-ratio-313919.internal> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 21, 2021 at 03:42:39PM +0000, Hyeonggon Yoo wrote: > > > + /* slowpath */ > > > + cache->size = kmem_cache_alloc_bulk(s, gfpflags, > > > + KMEM_LOCKLESS_CACHE_QUEUE_SIZE, cache->queue); > > > > Go back to the Bonwick paper and look at the magazine section again. > > You have to allocate _half_ the size of the queue, otherwise you get > > into pathological situations where you start to free and allocate > > every time. > > I want to ask you where idea of allocating 'half' the size of queue came from. > the paper you sent does not work with single queue(magazine). Instead, > it manages pool of magazines. > > And after reading the paper, I see managing pool of magazine (where M is > an boot parameter) is valid approach to reduce hitting slowpath. Bonwick uses two magazines per cpu; if both are empty, one is replaced with a full one. If both are full, one is replaced with an empty one. Our slab implementation doesn't provide magazine allocation, but it does provide bulk allocation. So translating the Bonwick implementation to our implementation, we need to bulk-allocate or bulk-free half of the array at any time.