Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4376316rdb; Mon, 11 Dec 2023 18:30:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IFU1TwlelI8UAwqEcunkg0wzL/8c/+m4eWc+WDny0XwW+8M7j8/m+FaOpzGtBG7akEAqKMy X-Received: by 2002:a05:6a20:734f:b0:17b:1f76:86ee with SMTP id v15-20020a056a20734f00b0017b1f7686eemr6174076pzc.16.1702348227774; Mon, 11 Dec 2023 18:30:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702348227; cv=none; d=google.com; s=arc-20160816; b=DsVlSN41Gua4W6r+OdFFEW9SlMGP7qMdfXxJueTnE3re5XWbAgHGgvBS+uH8lfIfa3 ZVdEpsUAD2k/dP3Fj2sVfUJnhabGQpFAcNM0USXFiOEWYBXaXQDwa+R5ssa2l7ex4ZJp /ubyevtwUGv9OIUF95i7nF/DN5V7Z8Xh8VofnsZTDqgjRTwjkbN8PGSFvEapADMY+JNM hU3FMlAu0eXq+Vc6V4gxie0Als6GyI6OGhk1Em7Fe2SRLEeKamlnBmKYnvXmbkUaYvqU bXdjxXFyJuaTBuBqEPsN/70AqJOM9/co3TnSevhGsF6naZoKKOmRqi0A5dJ48ILQrHu5 +mFg== 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=2DMiRTxcwheUb+ZoNiPcJzLnCeEFZ24O/DBbvQYnX0M=; fh=oaFiI/9/t0BWUNJVeVa8zavLj2zk5LJLOn+hQcwJIQI=; b=RePPMd7xJFS1xWv6MaaHouTOFBbpn66OOTvV/XLSbwIGbMjJR9cx50rB0NFf6v7MDg XEXT4tb/FFeLWFF/ZLjcgewdgTHbF84I2bZnbpsh9uBnsdUx6UA26BSpq/qSCvg/KiZJ ciOOfiZpuUaE9dCydlzd5ZQTqmjsTK2CASTGPx5uepT9jmiKJkDfBxDO3c44Jt1bBJi8 fRKVA8Ruuir/l1G/D2vmSDA7am5O4mPUL+aFRWQEs2KTGvRoYJ/B3+zcq6qFUbOfZl2r 4SoW2Qr1PHSvCgO/SUCvQRbZ6X3OtGb0EVGxf6qWKvxAuxUuZ74CgBFVFPPZ7FWdrcaJ OA6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=l23L7lV4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id c6-20020a631c46000000b005b99ea783aasi6847461pgm.755.2023.12.11.18.30.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 18:30:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=l23L7lV4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id F05BB8059899; Mon, 11 Dec 2023 18:30:02 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345825AbjLLC3j (ORCPT + 99 others); Mon, 11 Dec 2023 21:29:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345818AbjLLC2s (ORCPT ); Mon, 11 Dec 2023 21:28:48 -0500 Received: from mail-yb1-xb2c.google.com (mail-yb1-xb2c.google.com [IPv6:2607:f8b0:4864:20::b2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C425186 for ; Mon, 11 Dec 2023 18:28:45 -0800 (PST) Received: by mail-yb1-xb2c.google.com with SMTP id 3f1490d57ef6-db5e5647c24so5250866276.1 for ; Mon, 11 Dec 2023 18:28:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702348124; x=1702952924; 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=2DMiRTxcwheUb+ZoNiPcJzLnCeEFZ24O/DBbvQYnX0M=; b=l23L7lV4hh5lDkKy8WpQFYTkMrVEnXHT/E2pRwalsa8qbdIEvEVMsGaLXjFt7SKj6F MIckE0oRdoU28fWjsRIX58BJ77jDx9wwLvmo9KI1x1XI1ej1BxQfczXzlEwfW0gWd0df 3Mcnqthhv4LOk4HgS1On0PlFnc40JY6Rj6JnLgzkdOWSiLQscS/VBiC+ulZa5hrR6nRI /1X9UnZDkmJc3eALd2QGnvD6WMCDr+HiaS4jRMVt/oiHk+Bunw3yz7VylvdFmMYccYsc ts7EDvMEXXinINQeNKo/paSVpSvxjIHzEB+YDAn+gCIlEmEzMOrCTqeTz0QtxbOUZm7r lIoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702348124; x=1702952924; 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=2DMiRTxcwheUb+ZoNiPcJzLnCeEFZ24O/DBbvQYnX0M=; b=gOWs6WXK5GnAitVJPyIQ3CATxyec/J2LJLatPP2K9HwPSlLJ1gylBaTi58uMJZn6Ga NAJWiD5cItJqUpLIZVYx9SLPzRB+ekIXvQfKtKHGm57XT5EsigNhZdGWsju+Giq3HPl1 u9dF7yCXouTBM2JgxngcQtcA1G2aUQylI2EHw7nJp7AQNTb4yGl5xu/KMP+aRte+l+c2 z/PMAXq9JZuEREOr/i00N53UItaU9uJ7WeMh5rMl4M2/pSPME0kGUw3atJRAiQoXfnGU aiROJ7jZEOJrfGgRliF1soaOuNObcCP0DHJmlEL8iSNjImvx+XSDn5wyIKa18Mlbui4M KcsQ== X-Gm-Message-State: AOJu0YzPWbOlba0Swv7CgaLswSA/Iv2c8EZC1TQrcJovGT+SRLpEhM97 8BWfubKXrYRVWGMEiFmk6vznU1gv0BzsuA== X-Received: by 2002:a25:cc82:0:b0:dbc:b4dc:a8c9 with SMTP id l124-20020a25cc82000000b00dbcb4dca8c9mr687040ybf.15.1702348123771; Mon, 11 Dec 2023 18:28:43 -0800 (PST) Received: from localhost ([2601:344:8301:57f0:38aa:1c88:df05:9b73]) by smtp.gmail.com with ESMTPSA id x9-20020a25a009000000b00d9a36ded1besm2959103ybh.6.2023.12.11.18.28.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 18:28:43 -0800 (PST) From: Yury Norov To: linux-kernel@vger.kernel.org, Michal Simek , Yury Norov Cc: Jan Kara , Mirsad Todorovac , Matthew Wilcox , Rasmus Villemoes , Andy Shevchenko , Maxim Kuvyrkov , Alexey Klimov , Bart Van Assche , Sergey Shtylyov Subject: [PATCH v3 34/35] microblaze: optimize get_mmu_context() Date: Mon, 11 Dec 2023 18:27:48 -0800 Message-Id: <20231212022749.625238-35-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 fry.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 (fry.vger.email [0.0.0.0]); Mon, 11 Dec 2023 18:30:03 -0800 (PST) Simplify get_mmu_context() by using find_and_set_bit_wrap(). Signed-off-by: Yury Norov --- arch/microblaze/include/asm/mmu_context_mm.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/arch/microblaze/include/asm/mmu_context_mm.h b/arch/microblaze/include/asm/mmu_context_mm.h index c2c77f708455..209c3a62353a 100644 --- a/arch/microblaze/include/asm/mmu_context_mm.h +++ b/arch/microblaze/include/asm/mmu_context_mm.h @@ -82,12 +82,11 @@ static inline void get_mmu_context(struct mm_struct *mm) return; while (atomic_dec_if_positive(&nr_free_contexts) < 0) 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