From patchwork Thu Jan 11 11:24:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 13517225 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A89FCC4707B for ; Thu, 11 Jan 2024 11:25:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: Mime-Version:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=qf9azWJs56HftjYuAOdRKGnyfk2eHL1U2xKAMnpYFYo=; b=Z1b nnvSM6jqQVCGvDhGO/9dqp+sTW4TFM2P7K8CKQQ0Ja8ag5c1PZvWHt3rRQvBkLgtjW5/SsyDh3Deb CXZR+1YtKj3rpYcEd1lvZUI3PeFXmvR10KFobxqyO+r+rWSbk61jYgl2asMxp0U5ejANmdH9Fu8Ga Q5eG+Ufng+zTd0VXFKWPkmne4qbbtk9tStG4fBKNr4YV9Vw/cPwazQwMOHKX2DNxeZFinmMGtgUPE k4NV/TsfjALbeKiJ8F1SllL5/qts/op+V7ZMlsKmHcw6sk+e35DP5pdUjpbj6vxgs2WnsEXjdXpLS TmA2RZOfCfDElhFtLZJQLpDm59ooSdA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rNtBE-00HHIQ-20; Thu, 11 Jan 2024 11:25:00 +0000 Received: from mail-wr1-x449.google.com ([2a00:1450:4864:20::449]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rNtBC-00HHF2-1R for linux-arm-kernel@lists.infradead.org; Thu, 11 Jan 2024 11:24:59 +0000 Received: by mail-wr1-x449.google.com with SMTP id ffacd0b85a97d-336937b3cf5so3205750f8f.3 for ; Thu, 11 Jan 2024 03:24:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1704972295; x=1705577095; darn=lists.infradead.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=ra83CMA/66mvSPrOZ76luFPr0JoD0sUEUdHcJ/qKG3o=; b=QWpHHl+l2SNNvRTMdaWJ/HWbuRfDuMGYXauJRcfiBrykmW9Jm7WyPun98ry8ZlV/WT uYek/YI7ph/IoKNMlQzR64Ewp5/F9Y7nfRx09zBinEck8HSg01cu3aNqIp3fF8yr5sSE czhoTE65c+g+mEPJbD94MlWpc+YKdScr7IfBGalaz1DGK3uxq366u2RnJyliYa8Wr1Cv nIeZGu8bq1PBgLBV0pr7m8NfakmCsMohWYfHe8qexAv3ONTVXpBU+d2euY/MW4WOMcTI GTr73tw3rQ7xIGG5h63Aodyey/ull8ddOB3AZ8vDyMIc/CGxJS5h9lOknB4epsNsQxEr RlXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704972295; x=1705577095; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ra83CMA/66mvSPrOZ76luFPr0JoD0sUEUdHcJ/qKG3o=; b=XcUTTqUL6/kFEwB9XUVUwYy3XE4HzJg7sKJ7e7VGnQOxjSyEXPCajzPtIIe8gEI3et ufy7lziaGrdM4e8MhLCQgcLsPI38hbnAc/Dxt76uGnfI3lj++pHANxshNAYN2++/wFBZ 1jWp1FlW7ePnYlONQW0QbcZmHfFh5J/pT00wZlytbTZ3rdzoiDgMUIYbwQ7yk7hIPCSQ q8PMgf5waXfbpczw+BwFesGfRuYkwow0xj3glkDizJPu2+5+wuR9nDGxoWXN6p0oy/cE IWLciIgM3yPswOfueQkWmY5fSFoJhMxWiMjpyCruDyK6dcF7K7NxaCiRP6j1pizjjqxV Nq+g== X-Gm-Message-State: AOJu0YzaIu9IPgIMimaMSUKCDDKWM8XLmcio+eRwqkXn2+vsOKWcjIUb jpTfmNXVbymgNyp2MJX5FvJXyOmlc2CTogi1D825HXpIICKDjBUck5NH7P8/0Bb/91Ket7BKC5F rjPQvbbJtJVss2dw9gLzJPz1s0zIjeYcT12Ug7xo0h5oI5H/mNZiMJxhEFToj9BIGXINa3osBcs G5lBUW5Q== X-Google-Smtp-Source: AGHT+IHrgJJ9eYn8xj6B5cd74fFaVW06hkmro/EF6QuqAUG5uJ+5tlhwsRBSUz5+M84iJruBL7AlpPFw X-Received: from palermo.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:118a]) (user=ardb job=sendgmr) by 2002:adf:9d8e:0:b0:336:b83d:e6d0 with SMTP id p14-20020adf9d8e000000b00336b83de6d0mr2919wre.6.1704972295500; Thu, 11 Jan 2024 03:24:55 -0800 (PST) Date: Thu, 11 Jan 2024 12:24:48 +0100 Mime-Version: 1.0 X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=3397; i=ardb@kernel.org; h=from:subject; bh=r7Pq+JQK8BfrbNFpYx2yzr/AOf9wN2BQkuaQT7E0BNA=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIXX+BQbVswlin17s2mUTcWle2CaX1jDvJTc/yN6sXHMrR eavkJpaRykLgxgHg6yYIovA7L/vdp6eKFXrPEsWZg4rE8gQBi5OAZhIsysjw3LVJ1KTdqrfe28W d+OdMPditQt7BITmF7iKyNRKx1y9953hv4Pw4x2Wr+f872efeVdk6oLNjsuPqXi7PzxR9ZMhbff 7RVwA X-Mailer: git-send-email 2.43.0.275.g3460e3d667-goog Message-ID: <20240111112447.577640-2-ardb+git@google.com> Subject: [PATCH] arm64: fpsimd: Bring cond_yield asm macro in line with new rules From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: will@kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com, broonie@kernel.org, Ard Biesheuvel X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240111_032458_506692_CE1DCE68 X-CRM114-Status: GOOD ( 14.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Ard Biesheuvel We no longer disable softirqs or preemption when doing kernel mode SIMD, and so for fully preemptible kernels, there is no longer a need to do any explicit yielding (and for non-preemptible kernels, yielding is not needed either). That leaves voluntary preemption, where only explicit yield calls may result in a reschedule. To retain the existing behavior for such a configuration, we should take the new situation into account, where the preempt count will be zero rather than one, and yielding to pending softirqs is unnecessary. Fixes: aefbab8e77eb ("arm64: fpsimd: Preserve/restore kernel mode NEON at context switch") Signed-off-by: Ard Biesheuvel Reviewed-by: Mark Brown --- arch/arm64/include/asm/assembler.h | 25 +++++++++---------------- arch/arm64/kernel/asm-offsets.c | 2 -- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h index 7b1975bf4b90..513787e43329 100644 --- a/arch/arm64/include/asm/assembler.h +++ b/arch/arm64/include/asm/assembler.h @@ -760,32 +760,25 @@ alternative_endif .endm /* - * Check whether preempt/bh-disabled asm code should yield as soon as - * it is able. This is the case if we are currently running in task - * context, and either a softirq is pending, or the TIF_NEED_RESCHED - * flag is set and re-enabling preemption a single time would result in - * a preempt count of zero. (Note that the TIF_NEED_RESCHED flag is - * stored negated in the top word of the thread_info::preempt_count + * Check whether asm code should yield as soon as it is able. This is + * the case if we are currently running in task context, and the + * TIF_NEED_RESCHED flag is set. (Note that the TIF_NEED_RESCHED flag + * is stored negated in the top word of the thread_info::preempt_count * field) */ - .macro cond_yield, lbl:req, tmp:req, tmp2:req + .macro cond_yield, lbl:req, tmp:req, tmp2 +#ifdef CONFIG_PREEMPT_VOLUNTARY get_current_task \tmp ldr \tmp, [\tmp, #TSK_TI_PREEMPT] /* * If we are serving a softirq, there is no point in yielding: the * softirq will not be preempted no matter what we do, so we should - * run to completion as quickly as we can. + * run to completion as quickly as we can. The preempt_count field will + * have BIT(SOFTIRQ_SHIFT) set in this case, so the zero check will + * catch this case too. */ - tbnz \tmp, #SOFTIRQ_SHIFT, .Lnoyield_\@ -#ifdef CONFIG_PREEMPTION - sub \tmp, \tmp, #PREEMPT_DISABLE_OFFSET cbz \tmp, \lbl #endif - adr_l \tmp, irq_stat + IRQ_CPUSTAT_SOFTIRQ_PENDING - get_this_cpu_offset \tmp2 - ldr w\tmp, [\tmp, \tmp2] - cbnz w\tmp, \lbl // yield on pending softirq in task context -.Lnoyield_\@: .endm /* diff --git a/arch/arm64/kernel/asm-offsets.c b/arch/arm64/kernel/asm-offsets.c index 5ff1942b04fc..5a7dbbe0ce63 100644 --- a/arch/arm64/kernel/asm-offsets.c +++ b/arch/arm64/kernel/asm-offsets.c @@ -117,8 +117,6 @@ int main(void) DEFINE(DMA_FROM_DEVICE, DMA_FROM_DEVICE); BLANK(); DEFINE(PREEMPT_DISABLE_OFFSET, PREEMPT_DISABLE_OFFSET); - DEFINE(SOFTIRQ_SHIFT, SOFTIRQ_SHIFT); - DEFINE(IRQ_CPUSTAT_SOFTIRQ_PENDING, offsetof(irq_cpustat_t, __softirq_pending)); BLANK(); DEFINE(CPU_BOOT_TASK, offsetof(struct secondary_data, task)); BLANK();