Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4376606rdb; Mon, 11 Dec 2023 18:31:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IH4ZjfMzSldPPRtyCLgzWayeFOQ0fQYhJoBXmKiXi9RsRsxI37jwKS6eBKnQG1L8Uqj2UuB X-Received: by 2002:a17:90a:7523:b0:27d:3439:c141 with SMTP id q32-20020a17090a752300b0027d3439c141mr2493001pjk.39.1702348277313; Mon, 11 Dec 2023 18:31:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702348277; cv=none; d=google.com; s=arc-20160816; b=MNczNMziIaK5M4V4kCIOt81YLmKet9d/U7PqlxPElu3+cPzFDsQ57c7AmwAgPpncaF lX/boesLJb69fXqrLEUCmDhjZraHblLHzoch82ukHjUzkrTN+iGYnDy44gWY1lwozRyE yQM3LPxVzhl65Sg7Du32OqxjOLO2sNZtFZJtuT1dUG8BEwnqhD72CSzKGaZbvcUH7NyK 0QBn2Ln01BFH/l55uotY9jhao804JK57JADGcBCID23Sfcpgn3kM2Ba8rRkEwx/K86uO 6nSxpo3zIke2l2IIdtTUz+BtxzNLJfN5Wkx3xL8FCM3wM3nfTh5a/jV23VZ8b49Gn2Kl zAWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IDadoh3sC9nujQVrBPos5E8fmvZsF3sQWC418uY4Cbs=; fh=7CKtRTKIJQWky87pDsfZzHoo8TOWKn0Vo/v81eNSkgk=; b=FSmvUlM3gTKhcv9z+7v8U3joS7sDKbHHbUJ3AxvZGdpYZQOjsGszgZxY8i7DMK2uuG gDztTeUYJF1ZpOyjIw0Pkk010XCqKAQ1W/Y8lQqBnREsm+d/iKZ7qG+YppN88zS9HaRK iwhpih1C+m8ae7RuEtLY6reDntTRAvq/Qo6HpwwztpDZfJq5nStl8SIshc6GQHLcneDx PGkaPH4afCKr8fwUXKTvO2C8PLnO2JkYpxmXBlP58IWpTSvz4fe/ijbta5S+hvqMx+9c tJrYxGZ0LE0QuctIU4vNuL2W6taYTbHWTORduM8jWaXy7taed5vqpZrFM9uu2CR6bcsJ +yPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=dxdYWiQL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id i9-20020a1709026ac900b001d336801025si291627plt.255.2023.12.11.18.31.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 18:31:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=dxdYWiQL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 610AE80AF838; Mon, 11 Dec 2023 18:31:10 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345969AbjLLC3g (ORCPT + 99 others); Mon, 11 Dec 2023 21:29:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345816AbjLLC2s (ORCPT ); Mon, 11 Dec 2023 21:28:48 -0500 Received: from mail-yw1-x1129.google.com (mail-yw1-x1129.google.com [IPv6:2607:f8b0:4864:20::1129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD458EE for ; Mon, 11 Dec 2023 18:28:43 -0800 (PST) Received: by mail-yw1-x1129.google.com with SMTP id 00721157ae682-5d3758fdd2eso50362517b3.0 for ; Mon, 11 Dec 2023 18:28:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702348122; x=1702952922; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IDadoh3sC9nujQVrBPos5E8fmvZsF3sQWC418uY4Cbs=; b=dxdYWiQLlx6CnU5kD0QxPoqDd7uG5ayj5M9sjT1If/KWFku9+Pp/Xb4neP7pFZIy9e QHE8OovC+4K/D2pTyeKES56IdDB7r1HN+9c5PsZ5hsr1xrZ+5S44ev33Tp6/UILyrtgr zUTf3GHBtt6eA4PdTsrgs35ies93gFMr/NNHBQAj878cdAzwBUO2X/Z9F24yIaMK5pHg NoZlwIwmilOyRTiFfjY9jlhA+O19D7tLg59bcqzGfwCCeEtAcljr0MJOZXD58SczdXzL eGEv/+SK3DCk/3Q95YOeijOUrmFgzfnGKcLigVf2u7PSHrh72JJUWzotlSlTbGi52GEn Mmpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702348122; x=1702952922; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IDadoh3sC9nujQVrBPos5E8fmvZsF3sQWC418uY4Cbs=; b=WjPwH6iPTu/RCFf+nKwGFidWUWjLSL8NQbB0iovCnBuJ2ZGJOB4LWNlqys/iBnWMnG qod5+g1b2pxdFC0+vcXq1THbSfINfP/Ih6FzNWgzhdr/P+Gr9Tak1og44uFVOaOXqk9n gznrPNaamA5SCgPgiTJpM6ZK6TLG028lxPUGZTbFNLxIGSA0FPLwZgnvRJnQ7/rJH8Us iG3Dyr0AzAnvMyqwr9PROpIiAH2kst0iGhLzPg4N19La09g5Azd6dIJclK2dwBw5pjPs 2Ck0QXrGf5HgZ17LZltvW5LOKnKX81msP1Bhm7TmOyHH38007Ym+CUtkGcRH3+cZm001 Tc3g== X-Gm-Message-State: AOJu0YzRPIQyVMsprLvNc8F8n3azrQdYzKWB0SXxHc+GK2GhgNJk7xRm /Uu+SP04ZPb8D+vBcu33j2FQs8wqCBQ3Xg== X-Received: by 2002:a0d:cb83:0:b0:5ca:71fe:4dbc with SMTP id n125-20020a0dcb83000000b005ca71fe4dbcmr3774094ywd.49.1702348122349; Mon, 11 Dec 2023 18:28:42 -0800 (PST) Received: from localhost ([2601:344:8301:57f0:38aa:1c88:df05:9b73]) by smtp.gmail.com with ESMTPSA id s7-20020a815e07000000b005b34d8b33ffsm3432482ywb.119.2023.12.11.18.28.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 18:28:41 -0800 (PST) From: Yury Norov To: linux-kernel@vger.kernel.org, Geert Uytterhoeven , Hugh Dickins , Andrew Morton , Yury Norov , linux-m68k@lists.linux-m68k.org Cc: Jan Kara , Mirsad Todorovac , Matthew Wilcox , Rasmus Villemoes , Andy Shevchenko , Maxim Kuvyrkov , Alexey Klimov , Bart Van Assche , Sergey Shtylyov , Greg Ungerer Subject: [PATCH v3 33/35] m68k: optimize get_mmu_context() Date: Mon, 11 Dec 2023 18:27:47 -0800 Message-Id: <20231212022749.625238-34-yury.norov@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231212022749.625238-1-yury.norov@gmail.com> References: <20231212022749.625238-1-yury.norov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email 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 (howler.vger.email [0.0.0.0]); Mon, 11 Dec 2023 18:31:11 -0800 (PST) get_mmu_context() opencodes atomic find_and_set_bit_wrap(). Simplify it by using find_and_set_bit_wrap(). CC: Geert Uytterhoeven Signed-off-by: Yury Norov Acked-by: Greg Ungerer --- arch/m68k/include/asm/mmu_context.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/arch/m68k/include/asm/mmu_context.h b/arch/m68k/include/asm/mmu_context.h index 141bbdfad960..0419ad87a1c1 100644 --- a/arch/m68k/include/asm/mmu_context.h +++ b/arch/m68k/include/asm/mmu_context.h @@ -35,12 +35,11 @@ static inline void get_mmu_context(struct mm_struct *mm) atomic_inc(&nr_free_contexts); steal_context(); } - ctx = next_mmu_context; - while (test_and_set_bit(ctx, context_map)) { - ctx = find_next_zero_bit(context_map, LAST_CONTEXT+1, ctx); - if (ctx > LAST_CONTEXT) - ctx = 0; - } + + do { + ctx = find_and_set_bit_wrap(context_map, LAST_CONTEXT + 1, next_mmu_context); + } while (ctx > LAST_CONTEXT); + next_mmu_context = (ctx + 1) & LAST_CONTEXT; mm->context = ctx; context_mm[ctx] = mm; -- 2.40.1