From patchwork Tue Mar 14 18:59:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 13174933 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 35AA8C6FD1F for ; Tue, 14 Mar 2023 19:01:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 858A08E000F; Tue, 14 Mar 2023 15:01:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 791BB8E000B; Tue, 14 Mar 2023 15:01:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 609428E000C; Tue, 14 Mar 2023 15:01:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 19BCD8E000B for ; Tue, 14 Mar 2023 15:01:17 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id EB655AB2A1 for ; Tue, 14 Mar 2023 19:01:16 +0000 (UTC) X-FDA: 80568421752.04.5774E93 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf16.hostedemail.com (Postfix) with ESMTP id 7F8D918002F for ; Tue, 14 Mar 2023 19:01:14 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AMiVm1q7; spf=pass (imf16.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.129.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=1678820474; 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=YODf8AXpgD6ykZzDcEsYwcp2gHdgesDwmIA0wTIRMH29aUR+5JzzAvvl9z4kzSy+f1vjQ1 FVKy3hXqEOy3/8Sdfz5zoYLMOG39+aZPcAaH81Ekd8cVZuaBGX4bcc+MIA7CZh+kp2yJl9 fL54nb0UhOFlNxCMcLDl5y0y7IFwXuA= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AMiVm1q7; spf=pass (imf16.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.129.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=1678820474; a=rsa-sha256; cv=none; b=BUOd++/Qg+koj8DKskEA6XH1lG4ik0s5X2FJ3sZcWtMZJXmEJTbd/Rl1WRcjbBJc4AQJuq G7saJg9TO38H+aid0u2zAs7zS44ckhxstLbwdh8feQm9ayZBvlH2ak2Wzcy6dU5eS2IE// B+UnyHSqcsrk7XVY00rjFbP9OnBbqd0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678820473; 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=AMiVm1q731P0Dk5sNb0ibUxDC+5mRqVunEmedQLy11RHdScubCv6bTeYDQOWzfys4+Tj38 Rub4+TEWx/v9A5tQvNoRzm8TQ2TydDl8wPQ/wixaFh5dO1uF2A4ulKD1lIhmAK3FusS5gW 7C0zNMSaRniJPzrXmz8pEC8oQtgjKyc= 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-359-nFSnaC_BP_mQcwnztKYEjw-1; Tue, 14 Mar 2023 15:01:07 -0400 X-MC-Unique: nFSnaC_BP_mQcwnztKYEjw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 05ED6101A55E; Tue, 14 Mar 2023 19:01:05 +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 C894B140E95F; Tue, 14 Mar 2023 19:01:04 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id 67D854039C290; Tue, 14 Mar 2023 16:00:44 -0300 (-03) Message-ID: <20230314185951.678940741@redhat.com> User-Agent: quilt/0.67 Date: Tue, 14 Mar 2023 15:59:20 -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, Vlastimil Babka , Michal Hocko , Peter Xu , Marcelo Tosatti Subject: [PATCH v6 06/12] convert this_cpu_cmpxchg users to this_cpu_cmpxchg_local References: <20230314185914.836510860@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Rspamd-Queue-Id: 7F8D918002F X-Stat-Signature: di36jttu5miwh5npsmoz66nxajinsnsw X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1678820474-1108 X-HE-Meta: U2FsdGVkX18u7IlIXEAp1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hDqDs7nnRNQuEpxpEP8s1sCzclxopfvwV+3awKZEhktZdBZP24Oq9WqSnfahLV/DtP6QLb7M34ytlh89BxcuKYYq8j3V4HKxfvhtGu/8Ht6/FYGRxPoRAh9xC6hqf4t/DKh+poyKtw== 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);