From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4BDFCC2B9F8 for ; Tue, 25 May 2021 11:47:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D06FE61417 for ; Tue, 25 May 2021 11:47:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D06FE61417 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=techsingularity.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5F1016B006C; Tue, 25 May 2021 07:47:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5965E6B006E; Tue, 25 May 2021 07:47:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 391AD6B0070; Tue, 25 May 2021 07:47:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0188.hostedemail.com [216.40.44.188]) by kanga.kvack.org (Postfix) with ESMTP id 02BAE6B006C for ; Tue, 25 May 2021 07:47:23 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 8A33C81D6 for ; Tue, 25 May 2021 11:47:23 +0000 (UTC) X-FDA: 78179577966.26.CFF8EFD Received: from outbound-smtp22.blacknight.com (outbound-smtp22.blacknight.com [81.17.249.190]) by imf08.hostedemail.com (Postfix) with ESMTP id 593908019127 for ; Tue, 25 May 2021 11:47:13 +0000 (UTC) Received: from mail.blacknight.com (pemlinmail01.blacknight.ie [81.17.254.10]) by outbound-smtp22.blacknight.com (Postfix) with ESMTPS id 97782BAC1E 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) X-Rspamd-Queue-Id: 593908019127 Authentication-Results: imf08.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf08.hostedemail.com: domain of mgorman@techsingularity.net designates 81.17.249.190 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net X-Rspamd-Server: rspam04 X-Stat-Signature: cdctghrg5f7n5zhq77y71fdxoygpfacr X-HE-Tag: 1621943233-87880 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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