From mboxrd@z Thu Jan 1 00:00:00 1970 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 1FCE7C433DB for ; Fri, 12 Feb 2021 21:23:14 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (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 55C5C64DB2 for ; Fri, 12 Feb 2021 21:23:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 55C5C64DB2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=axtens.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4Dcmgg2khxzDwtb for ; Sat, 13 Feb 2021 08:23:11 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=axtens.net (client-ip=2607:f8b0:4864:20::52f; helo=mail-pg1-x52f.google.com; envelope-from=dja@axtens.net; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=axtens.net header.i=@axtens.net header.a=rsa-sha256 header.s=google header.b=jtrl4rTR; dkim-atps=neutral Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Dcmdc1xW9zDwl9 for ; Sat, 13 Feb 2021 08:21:23 +1100 (AEDT) Received: by mail-pg1-x52f.google.com with SMTP id t26so492333pgv.3 for ; Fri, 12 Feb 2021 13:21:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axtens.net; s=google; h=from:to:subject:in-reply-to:references:date:message-id:mime-version; bh=1XvoCECmT3plBnzkkShbH513g0PqtMrwBfSxXnTuz4M=; b=jtrl4rTRTNfdeUfERBe+i8OnVzvNKOFSbA1R2RDlyCReQu/Jtlj5OK/AmjCusU0q+W xX0XiW/dLFnGKqaRkurtus9XYm8GxQFxL4FyVK8TXEVPlysgT0KiWtjD5UYJbmVPQbj1 xGYZAiOfNbLS1cC1QOlVbaZ0v1cL8zEZqdqtE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:in-reply-to:references:date :message-id:mime-version; bh=1XvoCECmT3plBnzkkShbH513g0PqtMrwBfSxXnTuz4M=; b=QALZx+OQUR+NZqnz9ktVjZjbgjTwxRy0wwfPlXkJl9J0q7R0nA0nEIuQjhyfmmpeG2 Cg1AQzyqPOSKiP2Q0Cak7z1Iu3dBnOFBPod3ZC9+xMipcbMhurfKXgclKizeM5SmYuU4 h6RYLxUy3RoFydpVh7Zr5pnLBj3aqtiztqXMBnfou8koAsXQVr6Jxh+gT3cNEBkVi6/m Sx7j2Wpei2TN1nzSmLRD4T5tF7nLWMJ1Gg8la5OXrAmpK+YcvEvRjb1dYK9wP0oCBU45 Al1x5VQsdiJ2fyZeTwzNlMoOraQKh08CIaT/rc09691C50Ehtb8VR3hhuRChX3CBx4om sH2Q== X-Gm-Message-State: AOAM533QQ2N4KZM7KEQ2qrEnOX+/PXg61Rwz/oKvzHLJDsQpAdKeOQsL 9l5yApaQcaMNhz/pT6BsL//1TQ== X-Google-Smtp-Source: ABdhPJzJwHbl+rCCaT77OYMjE9995QNqGrh3Kxd0AeXSFpTATlPuMpMIJ44c1e9tj5ZLSfkqupUf2Q== X-Received: by 2002:aa7:8a99:0:b029:1a6:c8b8:1414 with SMTP id a25-20020aa78a990000b02901a6c8b81414mr4515942pfc.66.1613164879764; Fri, 12 Feb 2021 13:21:19 -0800 (PST) Received: from localhost (2001-44b8-111e-5c00-c245-dfb7-be39-91ab.static.ipv6.internode.on.net. [2001:44b8:111e:5c00:c245:dfb7:be39:91ab]) by smtp.gmail.com with ESMTPSA id v9sm7389773pjd.30.2021.02.12.13.21.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Feb 2021 13:21:19 -0800 (PST) From: Daniel Axtens To: "Christopher M. Riedl" , linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH v5 10/10] powerpc/signal64: Use __get_user() to copy sigset_t In-Reply-To: <20210203184323.20792-11-cmr@codefail.de> References: <20210203184323.20792-1-cmr@codefail.de> <20210203184323.20792-11-cmr@codefail.de> Date: Sat, 13 Feb 2021 08:21:16 +1100 Message-ID: <87v9axc78z.fsf@dja-thinkpad.axtens.net> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" "Christopher M. Riedl" writes: > Usually sigset_t is exactly 8B which is a "trivial" size and does not > warrant using __copy_from_user(). Use __get_user() directly in > anticipation of future work to remove the trivial size optimizations > from __copy_from_user(). Calling __get_user() also results in a small > boost to signal handling throughput here. Modulo the comments from Christophe, this looks good to me. It seems to do what it says on the tin. Reviewed-by: Daniel Axtens Do you know if this patch is responsible for the slightly increase in radix performance you observed in your cover letter? The rest of the series shouldn't really make things faster than the no-KUAP case... Kind regards, Daniel > > Signed-off-by: Christopher M. Riedl > --- > arch/powerpc/kernel/signal_64.c | 14 ++++++++++++-- > 1 file changed, 12 insertions(+), 2 deletions(-) > > diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c > index 817b64e1e409..42fdc4a7ff72 100644 > --- a/arch/powerpc/kernel/signal_64.c > +++ b/arch/powerpc/kernel/signal_64.c > @@ -97,6 +97,14 @@ static void prepare_setup_sigcontext(struct task_struct *tsk, int ctx_has_vsx_re > #endif /* CONFIG_VSX */ > } > > +static inline int get_user_sigset(sigset_t *dst, const sigset_t *src) > +{ > + if (sizeof(sigset_t) <= 8) > + return __get_user(dst->sig[0], &src->sig[0]); > + else > + return __copy_from_user(dst, src, sizeof(sigset_t)); > +} > + > /* > * Set up the sigcontext for the signal frame. > */ > @@ -701,8 +709,9 @@ SYSCALL_DEFINE3(swapcontext, struct ucontext __user *, old_ctx, > * We kill the task with a SIGSEGV in this situation. > */ > > - if (__copy_from_user(&set, &new_ctx->uc_sigmask, sizeof(set))) > + if (get_user_sigset(&set, &new_ctx->uc_sigmask)) > do_exit(SIGSEGV); > + > set_current_blocked(&set); > > if (!user_read_access_begin(new_ctx, ctx_size)) > @@ -740,8 +749,9 @@ SYSCALL_DEFINE0(rt_sigreturn) > if (!access_ok(uc, sizeof(*uc))) > goto badframe; > > - if (__copy_from_user(&set, &uc->uc_sigmask, sizeof(set))) > + if (get_user_sigset(&set, &uc->uc_sigmask)) > goto badframe; > + > set_current_blocked(&set); > > #ifdef CONFIG_PPC_TRANSACTIONAL_MEM > -- > 2.26.1