Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1805026rda; Tue, 24 Oct 2023 04:03:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGqA2QTq3yYtyUD5fc6wQ0F3UB+Ifa2VmARCK5K9C1rGv5icuA9bsQaBbJG2/oPeeNGbLCo X-Received: by 2002:a05:6e02:1c24:b0:352:a2c9:60ed with SMTP id m4-20020a056e021c2400b00352a2c960edmr15190614ilh.11.1698145416681; Tue, 24 Oct 2023 04:03:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698145416; cv=none; d=google.com; s=arc-20160816; b=k3/7j7fh4JeyCzDymSPIrPZpRXmJJqenf0ZE8FdtXAyzfndC6toHoYpob3d7yH0YAK DGcOBlO+AezI2r4ASrrsX2wtfVAaw8S6eLffzh4x7Ukz4hnmv8NiPLLcz8+CrrqdGcWU UkXlHDlGbG6CzsHcepb+vrYnZrvHUH8dNZ8dI1Ld2gvWm0Vh0kx481hothlwdvcjtRaR O1XSNMK++NzWmLr9aWfY+BmP0v08mFYtMV+H8F9TTUkovneD42gyQwmG6iV2xZpbxZ8w nfmaCdI65kCV951LR2D7CsnQLEY77irL5cd5WwB3T5OMx92OkYH2raueCZEQCasAK8c7 FUHw== 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=pnFxFP6a7DC4iJ/6GwDjjDb4geFq6Fz2jY2wNEaiS7k=; fh=i+5RhcsIuKunUL94U7Y3aMpna4dkJGL83X2sf85n1jo=; b=T75uPyMGk2m34ECZsZOYr3n5drPwDLPD7dyHdbT6C8gD+geQs8Iu+WOGIMhnia114k t84qvm0S3kQoTlUeAiJBVIwftOCwDDhM2EtbNiTeIatM597JfFwQ2vfJkXW8gzs0mA5r 5z3dR/QS5uBzNkl5jSstxR7srnh5S9efYbqbvwH6qm+tl8zTUJ/aYIdm3SxhGXE/bp+l e5rW506na/PXjexYZ21DGrTRYkltClQ4UHNfQLDqy91HbAdMHAo+1sPBDEzf2rZ7Vx0g udMSvvcTN5qm5/XVLrooHk1nvHmSyVnoo1yn+lw/mEQMnecvge91ibhs7unyB33YNN0f E7tQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=jKwIBvyP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id bu18-20020a632952000000b0056a36f9eb0esi8568064pgb.15.2023.10.24.04.03.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 04:03:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=jKwIBvyP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 9BE5E802FB88; Tue, 24 Oct 2023 04:03:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229629AbjJXLDX (ORCPT + 99 others); Tue, 24 Oct 2023 07:03:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbjJXLDW (ORCPT ); Tue, 24 Oct 2023 07:03:22 -0400 Received: from out-209.mta1.migadu.com (out-209.mta1.migadu.com [95.215.58.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83B1F109 for ; Tue, 24 Oct 2023 04:03:20 -0700 (PDT) Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1698145398; 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=pnFxFP6a7DC4iJ/6GwDjjDb4geFq6Fz2jY2wNEaiS7k=; b=jKwIBvyPM2uA62TA6wyKo/Lq3aaRaNCjr9vCoIifxAicQgMoTLgsuSkuh0uK10cuL7URWL FJsiTWdcjjlZq/hXmcivjEyoRlXg9Ba5f8aPyRNoEhvnDOj9YuwSsQWeULiMBB/yoLNFcP aaHspv/BG+IAoOZdZ0ILwo4e4by/JlE= Date: Tue, 24 Oct 2023 19:03:10 +0800 MIME-Version: 1.0 Subject: Re: [RFC PATCH v2 0/6] slub: Delay freezing of CPU partial slabs Content-Language: en-US To: "Christoph Lameter (Ampere)" , Vlastimil Babka Cc: penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, roman.gushchin@linux.dev, 42.hyeyoo@gmail.com, willy@infradead.org, pcc@google.com, tytso@mit.edu, maz@kernel.org, ruansy.fnst@fujitsu.com, vishal.moola@gmail.com, lrh2000@pku.edu.cn, hughd@google.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Chengming Zhou References: <20231021144317.3400916-1-chengming.zhou@linux.dev> <4134b039-fa99-70cd-3486-3d0c7632e4a3@suse.cz> 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: 7bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Tue, 24 Oct 2023 04:03:35 -0700 (PDT) On 2023/10/24 05:05, Christoph Lameter (Ampere) wrote: > On Mon, 23 Oct 2023, Vlastimil Babka wrote: > >>> For much of the frozen handling we must be holding the node list lock >>> anyways in order to add/remove from the list. So we already have a lock >>> that could be used to protect flag operations. >> >> I can see the following differences between the traditional frozen bit and >> the new flag: >> >> frozen bit advantage: >> - __slab_free() on an already-frozen slab can ignore list operations and >> list_lock completely >> >> frozen bit disadvantage: >> - acquire_slab() trying to do cmpxchg_double() under list_lock (see commit >> 9b1ea29bc0d7) > > > Ok so a slab is frozen if either of those conditions are met. That gets a bit complicated to test for. Can we just get away with the slab_node_partial flag? > > The advantage with the frozen state is that it can be changed with a cmpxchg together with some other values (list pointer, counter) that need updating at free and allocation. > > But frozen updates are rarer so maybe its worth to completely drop the frozen bit. If both need to be updates then we would have two atomic ops. One is the cmpxchg and the other the operation on the page flag. > This introduced page flag bit is using non-atomic operations, which is protected by the node list_lock. As for completely dropping the "frozen" bit, I find it hard because we have the DEACTIVATE_BYPASS optimization in get_freelist(), which clear the "frozen" bit without the synchronization of node list_lock. So __slab_free() still need to rely on the "frozen" bit for CPU active slab. This patch series mainly optimize the cmpxchg cost in moving partial slabs between node partial list and CPU partial list, and alleviate the contention of node list_lock meanwhile. Thanks!