Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4288226pxj; Tue, 25 May 2021 04:49:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7mlRD2+lRJH+t1HW7RG9tSRwGTbLRKsGV2K6SVYBCoyEqd0vRiBHoTJJG8Zeneq0BtVRJ X-Received: by 2002:aa7:db94:: with SMTP id u20mr31172495edt.381.1621943345273; Tue, 25 May 2021 04:49:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621943345; cv=none; d=google.com; s=arc-20160816; b=Nj3zAL6dA2dQNe1wKMXEmZCYZTIsur0zbzFac3WTFcSf5YLSepGKa6laErp7D26pZ9 8eiW4BIBDRWCLWWqxYvvU2jJFbpXFHIY+GYPwCT5oWmlV9j3FWz9tnuAbckROJTFBV3H /9U9JsfPud2wPb4JdrEj5N/raptzj31CdIOC7NP8dd9QD7F6TMe/A9/tXPjXXryj5iHZ 0eGtSH6NGNpZ9fS7SSze5HmayrKtDO7f/yjj00QTw3qWg8VzSOs8uazNHKfGMMMGljiU GFZ1MltcnMS454AdOoAkP+NAtTbXej4GUIqlLeCxXhrct1gGxNtZfGYvWB5iAVBIQ+3v rb1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=6lTl8me1mtlK+Fgwv12tPkZd9nxu2AxAAQnC++5NCmE=; b=LJYq5YosLOKrUatKUGOx9LeDBko/dqgRTg8nLZvEL0K4x8t45EwN9q83MWZmur6VqK 4OFI9Ue0YzZuAZP7M19Z8LQBL0/tNXt05o7O2LHq/gdzhV420E78ub1LfmvnSDWQAMpx t5VssSSgwrP+Gmdt2X6cKgP39rxE59KB8PvMsCrda6aUpDS7w9RmQQ1oiAbX7dXsKvSz p2F/1Wcl4Oi0IaW85kapW3kIQYMV5hcAbmhsL1qe+auOc8XmYiQxfQ2SvqMFB2Bg86O8 HzWlFVJYb860XzCLjQ8pp9plKyll+lTFl2+cfSvC0oRgsQihaBGN9pnIYFVZJXSHp8mo qhhQ== 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 f26si15339422ejf.128.2021.05.25.04.48.41; Tue, 25 May 2021 04:49:05 -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 S231304AbhEYLst (ORCPT + 99 others); Tue, 25 May 2021 07:48:49 -0400 Received: from outbound-smtp35.blacknight.com ([46.22.139.218]:50213 "EHLO outbound-smtp35.blacknight.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229896AbhEYLss (ORCPT ); Tue, 25 May 2021 07:48:48 -0400 Received: from mail.blacknight.com (pemlinmail01.blacknight.ie [81.17.254.10]) by outbound-smtp35.blacknight.com (Postfix) with ESMTPS id 97F821848 for ; Tue, 25 May 2021 12:47:17 +0100 (IST) Received: (qmail 2807 invoked from network); 25 May 2021 11:47:17 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.23.168]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 25 May 2021 11:47:17 -0000 Date: Tue, 25 May 2021 12:47:15 +0100 From: Mel Gorman To: Vlastimil Babka Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Christoph Lameter , David Rientjes , Pekka Enberg , Joonsoo Kim , Sebastian Andrzej Siewior , Thomas Gleixner , Jesper Dangaard Brouer , Peter Zijlstra , Jann Horn Subject: Re: [RFC 04/26] mm, slub: simplify kmem_cache_cpu and tid setup Message-ID: <20210525114715.GN30378@techsingularity.net> References: <20210524233946.20352-1-vbabka@suse.cz> <20210524233946.20352-5-vbabka@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20210524233946.20352-5-vbabka@suse.cz> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 25, 2021 at 01:39:24AM +0200, Vlastimil Babka wrote: > In slab_alloc_node() and do_slab_free() fastpaths we need to guarantee that > our kmem_cache_cpu pointer is from the same cpu as the tid value. Currently > that's done by reading the tid first using this_cpu_read(), then the > kmem_cache_cpu pointer and verifying we read the same tid using the pointer and > plain READ_ONCE(). > > This can be simplified to just fetching kmem_cache_cpu pointer and then reading > tid using the pointer. That guarantees they are from the same cpu. We don't > need to read the tid using this_cpu_read() because the value will be validated > by this_cpu_cmpxchg_double(), making sure we are on the correct cpu and the > freelist didn't change by anyone preempting us since reading the tid. > > Signed-off-by: Vlastimil Babka Wow, that's a fun approach to avoiding disabling preemption but the validation check against preemption remains the same so; Acked-by: Mel Gorman -- Mel Gorman SUSE Labs