Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp1545052rdh; Fri, 27 Oct 2023 19:37:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEOAKc22ESKXohD0igs598AiMAm+qkWWRnoL9EWa3/2XQkQrDl3iSS/84bVeC6BMUuWpPDJ X-Received: by 2002:a05:6871:7515:b0:1ea:406:4dff with SMTP id ny21-20020a056871751500b001ea04064dffmr5363461oac.50.1698460642809; Fri, 27 Oct 2023 19:37:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698460642; cv=none; d=google.com; s=arc-20160816; b=tH1bNoYW5PiYWXBglwRnWFodfVR7hCLPzBSfHmLRSeK6q9VEugsXUHwAV6uaoS29z2 ZO5cU+YvCf+aed6UegfCDvRnb5KHt2iSbav3CeyE5hWH7yS1VNEse+m2cfxOaH12N9iG M70NHzVfiMZXWERhkQtzZOsUCvQVWevw8M/b7LwswWEVhAl/9wCqhmEZ+W3nsHahGli3 2zs8ulpAGrWf6tEZazsqc6zawdaMd0V9Soo1qUcOWhCi4tnjU27oR5F7FSQA/qiQzaPF 2XiZwIrPzbEGGSrSc9xQk0NgrSXwoNYTa3OLhgUeLKVgrVIr2La3LdlIrYYksxjr2bqe S1og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:mime-version:date :dkim-signature:message-id; bh=etADSky/OaS5gb1oFEUv8DDHiwK9mtB5pub2uxFo0DE=; fh=qZEa00HW1MkAkhF0dIbt7BM2SqW++KQMN8/PCNrY7XA=; b=bk4kA4bAlHBT9bKRTNfkzDzoGPYwMY7hDBDMtXYoxN7fNDMMpOBtZFi5hlUaSpbPmr rX9JeHRa4RYYgWIa/m4GHrdtDRVrzwArh2293GI3an57VVaT4JG2B1zr76Olpl4RFHI/ ig78pGMgl7CxUXmZiKLg1hb5sR0juuMvqrn060ujBm6UT1Y9XbFHVbQ9UXms6FibyKw9 dBIELm/ULUJICRQQZWF7uvNtN4kIGGS2uJs+/W80sGV4BGuWBHAlb25jinKBuGGK6bdJ c0+HjEhFtuyF33nWxqyLO7JLf/3u7zHj+A2Vdlk1VnE3yDP9EjPR3KhE0ahFU+QZim2Z 5SyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=JBIXHfvv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id k198-20020a636fcf000000b005ad35f5a7basi1808239pgc.507.2023.10.27.19.37.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 19:37:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=JBIXHfvv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 3710E83EB304; Fri, 27 Oct 2023 19:37:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229507AbjJ1Cgw (ORCPT + 99 others); Fri, 27 Oct 2023 22:36:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229446AbjJ1Cgv (ORCPT ); Fri, 27 Oct 2023 22:36:51 -0400 Received: from out-188.mta1.migadu.com (out-188.mta1.migadu.com [95.215.58.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B23590 for ; Fri, 27 Oct 2023 19:36:48 -0700 (PDT) Message-ID: <1199315b-63ce-4be4-8cde-b8b2fd29f91a@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1698460606; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=etADSky/OaS5gb1oFEUv8DDHiwK9mtB5pub2uxFo0DE=; b=JBIXHfvv6v6VjGZ7MkMAqlT/c8McEQ/IlWxR4Vubo0TTQ/milFi/eOpUg+uHg3TYbcYPtW 9bWPUFozKc1+MLs7/igxV/A4WuSZ2pVqWoracRM2KtpwSAp1kgPzuTZ+b9+LVFdlsNeF8k 1YqmLMLmk+4UKYC8EEWzyYbJoYVZKYM= Date: Sat, 28 Oct 2023 10:36:08 +0800 MIME-Version: 1.0 Subject: Re: [RFC PATCH v3 0/7] slub: Delay freezing of CPU partial slabs Content-Language: en-US To: Christoph Lameter Cc: penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, vbabka@suse.cz, roman.gushchin@linux.dev, 42.hyeyoo@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Chengming Zhou References: <20231024093345.3676493-1-chengming.zhou@linux.dev> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Chengming Zhou In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 27 Oct 2023 19:37:20 -0700 (PDT) On 2023/10/28 01:57, Christoph Lameter wrote: > On Tue, 24 Oct 2023, chengming.zhou@linux.dev wrote: > >> 2. Solution >> =========== >> We solve these problems by leaving slabs unfrozen when moving out of >> the node partial list and on CPU partial list, so "frozen" bit is 0. >> >> These partial slabs won't be manipulate concurrently by alloc path, >> the only racer is free path, which may manipulate its list when !inuse. >> So we need to introduce another synchronization way to avoid it, we >> reuse PG_workingset to keep track of whether the slab is on node partial >> list or not, only in that case we can manipulate the slab list. >> >> The slab will be delay frozen when it's picked to actively use by the >> CPU, it becomes full at the same time, in which case we still need to >> rely on "frozen" bit to avoid manipulating its list. So the slab will >> be frozen only when activate use and be unfrozen only when deactivate. > > I think we have to clear our terminology a bit about what a "frozen" slab is. Yes, we need to clean up these inconsistent documentations in the source. > > Before this patch a frozen slab is not on the node partial list and therefore its state on the list does not have to be considered during freeing and other operations. The frozen slab could be actively allocated from. > > From the source: > > *   Frozen slabs >  * >  *   If a slab is frozen then it is exempt from list management. It is not >  *   on any list except per cpu partial list. The processor that froze the ~~ except per cpu partial list ~~ Frozen slab is not on any list, it's actively allocated from by the processor that froze it. IOW, frozen slab is the cpu slab. >  *   slab is the one who can perform list operations on the slab. Other >  *   processors may put objects onto the freelist but the processor that >  *   froze the slab is the only one that can retrieve the objects from the >  *   slab's freelist. >  * This part I think is unchanged. > > > After this patch the PG_workingset indicates the state of being on the partial lists. > > What does "frozen slab" then mean? The slab is being allocated from? Is that information useful or can we drop the frozen flag? Right, frozen slab is the cpu slab, which is being allocated from by the cpu that froze it. IMHO, the "frozen" bit is useful because: 1. PG_workingset is only useful on partial slab, which indicates the slab is on the node partial list, so we can manipulate its list in the __slab_free() path. 2. But for full slab (slab->freelist == NULL), PG_workingset is not much useful, we don't safely know whether it's used as the cpu slab or not just from this flag. So __slab_free() still rely on the "frozen" bit to know it. 3. And the maintaining of "frozen" has no extra cost now, since it's changed together with "freelist" and other counter using cmpxchg, we already have the cmpxchg when start to use a slab as the cpu slab. Maybe I missed something, I don't know how to drop the frozen flag. > > Update the definition? > Ok, will add a cleanup patch to update. Thanks!