From patchwork Fri Mar 3 19:58:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 13159449 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B40BC7EE32 for ; Fri, 3 Mar 2023 20:00:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 33BB96B0081; Fri, 3 Mar 2023 15:00:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2E9B36B0078; Fri, 3 Mar 2023 15:00:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 093246B0083; Fri, 3 Mar 2023 15:00:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C309A6B0080 for ; Fri, 3 Mar 2023 15:00:39 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 8FEFB14142A for ; Fri, 3 Mar 2023 20:00:39 +0000 (UTC) X-FDA: 80528654598.23.CD0E907 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf07.hostedemail.com (Postfix) with ESMTP id A519640023 for ; Fri, 3 Mar 2023 20:00:36 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=F5g96e2w; spf=pass (imf07.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=mtosatti@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677873637; a=rsa-sha256; cv=none; b=ATxeuIq4/V8kTR0obanu4RUTBdPgeeTSa76GxnU3X7wcotil3KLCleTW6dN9y0p2GFyRq5 7eJXT3iocC62D/nHGJiz+r1H435gOSVwwhYJ7gX8F1dJSXcRQzTn8veqeFGGd08aXPDMDZ GjywtIpWrUL3LyX4CWvD05I6o4AjmI0= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=F5g96e2w; spf=pass (imf07.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=mtosatti@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677873637; h=from:from:sender: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:in-reply-to: references:references:dkim-signature; bh=4jas7+kZOWWtovsxw7rARjyOL6nO08FiGsNhXOwYk0U=; b=Tn4tuY6ATvkuWSA0VPMMU185WosRail9oX0rePgqe/CvNqG/wPiN6BJRvLHXEpoSGEVumj gsACplCX+rbZWPxdFRi9d/ZYMkfWnz82Wb6Nsx4x0M3hoj0CPb/LaTz7STaq0WukxSCt9Y 56zExahUmR3MWncborW94DUV4rHM3B4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677873636; 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: references:references; bh=4jas7+kZOWWtovsxw7rARjyOL6nO08FiGsNhXOwYk0U=; b=F5g96e2wznCSan//sgQ3LR0YBN1wsPKkjOYww1NA9ZZBD/Lol6YWCJxYgUBkEubFEJFNeY yY6l73FwTm2xB+U3lXeakHIeD2pwrRKgTYe5nTGZ/W7GUEe4no7KYHSpK8lVoTvgSVWr4s mY1NZyRhY3cJezibppZxa/NUfdB/tnY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-70-XHhHsPN-OM-HKLtx0grcWA-1; Fri, 03 Mar 2023 15:00:32 -0500 X-MC-Unique: XHhHsPN-OM-HKLtx0grcWA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3AA4F80D0F1; Fri, 3 Mar 2023 20:00:32 +0000 (UTC) Received: from tpad.localdomain (ovpn-112-2.gru2.redhat.com [10.97.112.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0612A492C14; Fri, 3 Mar 2023 20:00:32 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id A344242919630; Fri, 3 Mar 2023 17:00:12 -0300 (-03) Message-ID: <20230303195908.926950608@redhat.com> User-Agent: quilt/0.67 Date: Fri, 03 Mar 2023 16:58:48 -0300 From: Marcelo Tosatti To: Christoph Lameter Cc: Aaron Tomlin , Frederic Weisbecker , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Russell King , Huacai Chen , Heiko Carstens , x86@kernel.org, Peter Xu , Marcelo Tosatti Subject: [PATCH v3 07/11] convert this_cpu_cmpxchg users to this_cpu_cmpxchg_local References: <20230303195841.310844446@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Rspam-User: X-Rspamd-Queue-Id: A519640023 X-Rspamd-Server: rspam01 X-Stat-Signature: necbjn4kmqdjq5p6atzjqdfp3i3j1a4i X-HE-Tag: 1677873636-434849 X-HE-Meta: U2FsdGVkX1905xX0O66moTvh8C2dJN/Q3ZV6W582HyjP3b5y7vp4YGYVrLhzBiv7r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br7vhgktbMTJLl8QhuDO+d6n2pbJAcI0C1HhXiaVZ3KaD5gbFTSJY2wMctTzlz2BntYtwTwfcfwxCHXlnTMoRuBELIGd5ygFZdVTw== 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: this_cpu_cmpxchg was modified to atomic version, which can be more costly than non-atomic version. Switch users of this_cpu_cmpxchg to this_cpu_cmpxchg_local (which preserves pre-non-atomic this_cpu_cmpxchg behaviour). Acked-by: Peter Xu Signed-off-by: Marcelo Tosatti Index: linux-vmstat-remote/kernel/fork.c =================================================================== --- linux-vmstat-remote.orig/kernel/fork.c +++ linux-vmstat-remote/kernel/fork.c @@ -203,7 +203,7 @@ static bool try_release_thread_stack_to_ unsigned int i; for (i = 0; i < NR_CACHED_STACKS; i++) { - if (this_cpu_cmpxchg(cached_stacks[i], NULL, vm) != NULL) + if (this_cpu_cmpxchg_local(cached_stacks[i], NULL, vm) != NULL) continue; return true; } Index: linux-vmstat-remote/kernel/scs.c =================================================================== --- linux-vmstat-remote.orig/kernel/scs.c +++ linux-vmstat-remote/kernel/scs.c @@ -83,7 +83,7 @@ void scs_free(void *s) */ for (i = 0; i < NR_CACHED_SCS; i++) - if (this_cpu_cmpxchg(scs_cache[i], 0, s) == NULL) + if (this_cpu_cmpxchg_local(scs_cache[i], 0, s) == NULL) return; kasan_unpoison_vmalloc(s, SCS_SIZE, KASAN_VMALLOC_PROT_NORMAL);