Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9297FC4363A for ; Thu, 29 Oct 2020 17:17:12 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EBA6520759 for ; Thu, 29 Oct 2020 17:17:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="U0i0TnUC"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=kernel-dk.20150623.gappssmtp.com header.i=@kernel-dk.20150623.gappssmtp.com header.b="ZDTu16mh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EBA6520759 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ZAwKbA3pxRm39BJNf/xarVbkbvdAV6V6tCdJAP8T130=; b=U0i0TnUCCv/+ZrZuI2vpHz44P dQMbyrWyYEJPLlaWn8s8qJ4TasjH/4dzXqmuE16pCqLzShCp01I4LNrcBh+E16f/abXi2LO/oTztm V5W18Tji/QbG9ecB4ryK5WutuKogw0EJrz5XAB7muX0t6vBlcPyzv5oXSDRO2RXWjFG1medUCyj3g jH76wRwZY+a0TNDns9F/9cdNwjVTlQsnL7IlRc1RWfzAeOo7jJKu+KkVjFdasqFvlso0i4OdH70gC 5uNkeeZx+VPS+IRGBJKf7tzsWNFKkslDO7PvbHZpkaWcJO/MGkscNv9ugZR5zl4mzRHoiLv3kavAD u1NgtjAKw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kYBWY-000506-Go; Thu, 29 Oct 2020 17:15:42 +0000 Received: from mail-io1-xd41.google.com ([2607:f8b0:4864:20::d41]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kYBWW-0004zJ-73 for linux-arm-kernel@lists.infradead.org; Thu, 29 Oct 2020 17:15:41 +0000 Received: by mail-io1-xd41.google.com with SMTP id b15so4314518iod.13 for ; Thu, 29 Oct 2020 10:15:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=BcF/qocHU0b0uFYV99Yodkix6rjBSx4IqtaocfPeuow=; b=ZDTu16mhTlpmymORaWPhSBn4CKy6M8LwVhWwpJ+kQnHJ/Xc1fZ709sEVTJE98URlmR vFUInIX0Eu4Lyci8CvBiVQYH1G9r3zwXmREP0qHRou3d+4WQPqjeLejk7t1VQJg0XATS NUlTiQIZ1vNR4O0zhOr+phKTIQTL47aBq/qwGw4LiaingjPR2XvJRx0Mc4tox65aPCsy YHOyzQxWOqCoAJj+19l1yl/AOivV9Nx0V/vDpuMyIME74Fdtx3WxmMzuJKr9Bl6mJXcx 7nyuOAi2NyJ3RguUIkJ/abZdyVttzW06/BLopTrrUkclrlpHoWwR4DzVRccakPM/lxXl TA8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=BcF/qocHU0b0uFYV99Yodkix6rjBSx4IqtaocfPeuow=; b=HDDq1OQ8FpOwjfaxCDEX0vsoygi+9EdawiqiWRxhMlRtISOtMuQVjiEDsZvICWAaoE ReF/LUJ1m3sPH95vtvs19IvuTa7iW5mJsg2CxDtLYL37vj3X2Qp01zzcyAeWw0+Rejye Cg+ChReG3b5MhUm+CZO++xE1YUxjwm2SaLYxnM5XMRvwaE2/9NuSu3zml0Bw430Cj53x uxYLAgxfcgWENzjdNqjZa9k+q1noe6SeXs5liiK2e3hQ4G99qjHa6vbH95ohr+DIDS6t dcFf5RDJe7jkczQrD6209LK6bs8fb07ppVhi8s+ExYs/+BdVjuD3InHoJBf1AN04RNoi MdNg== X-Gm-Message-State: AOAM532Wd0JaciT7YcB8LUc2cjuNwCCpCtYZN/+4mJo2XEq49e3TFvlU Axn3KQ9nBeLASxyOJXDMWWJ3hoALK7+VMQ== X-Google-Smtp-Source: ABdhPJwKP0Uo6xRbVaF8mUEfisS6WOFh7dIW85eno8MA/xJcMrL5/Is5u8rC9tPLj3OqgF3Y+nJwHw== X-Received: by 2002:a6b:b5c2:: with SMTP id e185mr4305532iof.106.1603991738344; Thu, 29 Oct 2020 10:15:38 -0700 (PDT) Received: from [192.168.1.30] ([65.144.74.34]) by smtp.gmail.com with ESMTPSA id d14sm2674227ila.42.2020.10.29.10.15.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Oct 2020 10:15:37 -0700 (PDT) Subject: Re: [PATCH] arm: add support for TIF_NOTIFY_SIGNAL To: Russell King - ARM Linux admin References: <3c1ebfa5-38d9-e6b2-fcf7-d8b17c0fa515@kernel.dk> <20201029162934.GX1551@shell.armlinux.org.uk> <20201029170110.GY1551@shell.armlinux.org.uk> From: Jens Axboe Message-ID: <3a512c06-8387-e989-af5c-d9698d42cb11@kernel.dk> Date: Thu, 29 Oct 2020 11:15:37 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20201029170110.GY1551@shell.armlinux.org.uk> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201029_131540_410972_7C787207 X-CRM114-Status: GOOD ( 30.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "linux-arm-kernel@lists.infradead.org" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 10/29/20 11:01 AM, Russell King - ARM Linux admin wrote: > On Thu, Oct 29, 2020 at 10:35:54AM -0600, Jens Axboe wrote: >> On 10/29/20 10:29 AM, Russell King - ARM Linux admin wrote: >>> On Thu, Oct 29, 2020 at 10:11:07AM -0600, Jens Axboe wrote: >>>> Wire up TIF_NOTIFY_SIGNAL handling for arm. >>>> >>>> Cc: linux-arm-kernel@lists.infradead.org >>>> Signed-off-by: Jens Axboe >>>> --- >>>> >>>> 5.11 has support queued up for TIF_NOTIFY_SIGNAL, see this posting >>>> for details: >>>> >>>> https://lore.kernel.org/io-uring/20201026203230.386348-1-axboe@kernel.dk/ >>>> >>>> As part of that work, I'm adding TIF_NOTIFY_SIGNAL support to all archs, >>>> as that will enable a set of cleanups once all of them support it. >>>> >>>> This needs a bit of asm help, immediate doesn't like anything outside >>>> of 1 byte, it seems. Any clues? >>> >>> Correct - immediates take an 8 bit value shifted by an even number of >>> bits. >>> >>> I'm tempted to suggest that we simplify things by making TIF bits 0..15 >>> invoke do_work_pending() no matter what - which will require a comment >>> in thread_info.h that all those bits will have that effect. The >>> resulting assembly would be: >>> >>> ldr r1, [tsk, #TI_FLAGS] @ re-check for syscall tracing >>> - tst r1, #_TIF_SYSCALL_WORK | _TIF_WORK_MASK >>> + movs r1, r1, lsl #16 >>> >>> which avoids the additional load caused by "ldr r2, =..." >>> >>> It's not like we're desperate for bits here. >> >> So renumber TIF bits that don't need to worry about do_work_pending() > >> 15 then? I agree, there's plenty of bits available, so seems reasonable >> to me. But probably more work in terms of other bits being tested with >> tstcurrently - at least when I looked, I could not find any of them I >> could successfully remap from < 8 to > 8. >> >> Any chance I can talk you into hacking that up? > > I don't believe that there's any need to do any renumbering. You are right! > _TIF_WORK_MASK covers bits 0-3. _TIF_SYSCALL_WORK covers bits 4-7. > Then we have 17, 18, and 20 which are not used to trigger the > do_work_pending(). > > So, I think it's just a case of changing what you're doing in the > assembly to my suggestion, and adding a comment to thread_info.h > noting that bits 0-15 will trigger a call into do_work_pending() > when returning to userspace. How about this? commit c03932936d8f99ff7c1c6c7d984e7a457284396c Author: Jens Axboe Date: Fri Oct 9 16:00:49 2020 -0600 arm: add support for TIF_NOTIFY_SIGNAL Wire up TIF_NOTIFY_SIGNAL handling for arm. Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Jens Axboe diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h index 536b6b979f63..eb7ce2747eb0 100644 --- a/arch/arm/include/asm/thread_info.h +++ b/arch/arm/include/asm/thread_info.h @@ -126,6 +126,8 @@ extern int vfp_restore_user_hwstate(struct user_vfp *, * thread information flags: * TIF_USEDFPU - FPU was used by this task this quantum (SMP) * TIF_POLLING_NRFLAG - true if poll_idle() is polling TIF_NEED_RESCHED + * + * Any bit in the range of 0..15 will cause do_work_pending() to be invoked. */ #define TIF_SIGPENDING 0 /* signal pending */ #define TIF_NEED_RESCHED 1 /* rescheduling necessary */ @@ -135,6 +137,7 @@ extern int vfp_restore_user_hwstate(struct user_vfp *, #define TIF_SYSCALL_AUDIT 5 /* syscall auditing active */ #define TIF_SYSCALL_TRACEPOINT 6 /* syscall tracepoint instrumentation */ #define TIF_SECCOMP 7 /* seccomp syscall filtering active */ +#define TIF_NOTIFY_SIGNAL 8 /* signal notifications exist */ #define TIF_USING_IWMMXT 17 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */ @@ -148,6 +151,7 @@ extern int vfp_restore_user_hwstate(struct user_vfp *, #define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT) #define _TIF_SECCOMP (1 << TIF_SECCOMP) +#define _TIF_NOTIFY_SIGNAL (1 << TIF_NOTIFY_SIGNAL) #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT) /* Checks for any syscall work in entry-common.S */ @@ -158,7 +162,8 @@ extern int vfp_restore_user_hwstate(struct user_vfp *, * Change these and you break ASM code in entry-common.S */ #define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \ - _TIF_NOTIFY_RESUME | _TIF_UPROBE) + _TIF_NOTIFY_RESUME | _TIF_UPROBE | \ + _TIF_NOTIFY_SIGNAL) #endif /* __KERNEL__ */ #endif /* __ASM_ARM_THREAD_INFO_H */ diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S index 271cb8a1eba1..77d16390a524 100644 --- a/arch/arm/kernel/entry-common.S +++ b/arch/arm/kernel/entry-common.S @@ -53,7 +53,7 @@ __ret_fast_syscall: cmp r2, #TASK_SIZE blne addr_limit_check_failed ldr r1, [tsk, #TI_FLAGS] @ re-check for syscall tracing - tst r1, #_TIF_SYSCALL_WORK | _TIF_WORK_MASK + movs r1, r1, lsl #16 bne fast_work_pending @@ -90,7 +90,7 @@ __ret_fast_syscall: cmp r2, #TASK_SIZE blne addr_limit_check_failed ldr r1, [tsk, #TI_FLAGS] @ re-check for syscall tracing - tst r1, #_TIF_SYSCALL_WORK | _TIF_WORK_MASK + movs r1, r1, lsl #16 beq no_work_pending UNWIND(.fnend ) ENDPROC(ret_fast_syscall) @@ -131,7 +131,7 @@ ENTRY(ret_to_user_from_irq) cmp r2, #TASK_SIZE blne addr_limit_check_failed ldr r1, [tsk, #TI_FLAGS] - tst r1, #_TIF_WORK_MASK + movs r1, r1, lsl #16 bne slow_work_pending no_work_pending: asm_trace_hardirqs_on save = 0 diff --git a/arch/arm/kernel/entry-v7m.S b/arch/arm/kernel/entry-v7m.S index de1f20624be1..d0e898608d30 100644 --- a/arch/arm/kernel/entry-v7m.S +++ b/arch/arm/kernel/entry-v7m.S @@ -59,7 +59,7 @@ __irq_entry: get_thread_info tsk ldr r2, [tsk, #TI_FLAGS] - tst r2, #_TIF_WORK_MASK + movs r2, r2, lsl #16 beq 2f @ no work pending mov r0, #V7M_SCB_ICSR_PENDSVSET str r0, [r1, V7M_SCB_ICSR] @ raise PendSV diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c index 585edbfccf6d..9d2e916121be 100644 --- a/arch/arm/kernel/signal.c +++ b/arch/arm/kernel/signal.c @@ -655,7 +655,7 @@ do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall) if (unlikely(!user_mode(regs))) return 0; local_irq_enable(); - if (thread_flags & _TIF_SIGPENDING) { + if (thread_flags & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL)) { int restart = do_signal(regs, syscall); if (unlikely(restart)) { /* -- Jens Axboe _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel