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 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 07DD2C98328 for ; Sat, 26 Sep 2026 12:49:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=VcwH+9dD3jn1cikX304Fn2/psmP9ex3vbb4X9xZ4y0w=; b=Wc0nricGL7CBj2a/XWP5RxzbyX qvcNkfvFMePemegmDMkatkLZ1EXvC5cY26K2lK+koRGuezvJAvdQ0N4Zp0/dP9M7YZD2uRQzsf0+4 SSLLEKzls2MjoAD/QvxT2JYMYWVyO05I0mvMDmR/hRbd4RcJBg0H+7Ck4uxtZnEAceUXNJa9cvsZ0 w+kmT0/k/QcJUxLJ4al3L+VQwggv1RB7NnU5KSErSDF33spuDYI4CHcEHpupWiwrT8yw57o2nATLe rWFMmCefMwk9dPgkXIarzxpUqj8q0aq5DClDmxW9MwqE7ZNPe1MXeMjtlX84vaHz3YYBkl69oE2Lo fBeayqaw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1xARqg-0000000FPAm-1ddZ; Sat, 26 Sep 2026 12:49:50 +0000 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1xARqe-0000000FPAd-1h9p; Sat, 26 Sep 2026 12:49:48 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id AC4E943D49; Sat, 26 Sep 2026 12:49:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6DC21F000FF; Sat, 26 Sep 2026 12:49:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790426987; bh=VcwH+9dD3jn1cikX304Fn2/psmP9ex3vbb4X9xZ4y0w=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=fd5egb/9VQIjjOqS4QVt0JCgY3CjQEWPCjDbq1JPvTO/u/NWzV+lbMU2GnucpD8Cg fQBncBItUBiNpft5Xle3TNZkvASdQXwYT782WczpRC4jNHKnURx/VR4lMI4JBZAg4b za0ej8mPU5YqIeMJVF26LmaALHmhJznID0Q97bqr7HNfNTSy14hNnajBL2yZtPoDr6 ZPeKxz/NhMbw/6kJedmpg94MnX+XYJsijQGDTgqkeXja/IGUPPqM+mRcQX86S0NU8a AaymHjbxISsM0nBUg8bnqDkatbTzLbXwZiMwQwM34QeqRDonyX/y1rrUsoEZSMn7fp RycokNiL9jKuw== Date: Sat, 26 Sep 2026 13:49:38 +0100 From: Nathan Chancellor To: "Jason A. Donenfeld" Cc: Andreas Schwab , Andy Lutomirski , Thomas Gleixner , Theodore Ts'o , Vincenzo Frascino , Nick Desaulniers , Bill Wendling , Justin Stitt , Catalin Marinas , Will Deacon , Mark Rutland , Huacai Chen , WANG Xuerui , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , "Christophe Leroy (CS GROUP)" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, loongarch@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, llvm@lists.linux.dev Subject: Re: [PATCH v2] random: vDSO: Avoid call to memset() when zeroing reserved in __cvdso_getrandom_data() Message-ID: <20260926124938.GC1486962@ax162> References: <20260925-vdso-getrandom-avoid-memset-llvm-24-v2-1-ce640f872393@kernel.org> <87zex4ic68.fsf@linux-m68k.org> <20260926121927.GA1486962@ax162> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 On Sat, Sep 26, 2026 at 02:32:49PM +0200, Jason A. Donenfeld wrote: > On Sat, Sep 26, 2026 at 01:19:27PM +0100, Nathan Chancellor wrote: > > On Sat, Sep 26, 2026 at 11:39:43AM +0200, Andreas Schwab wrote: > > > On Sep 25 2026, Nathan Chancellor wrote: > > > > > > > +#if __has_builtin(__builtin_memset_inline) > > > > +#define memset_inline(dst, value, size) __builtin_memset_inline(dst, value, size) > > > > +#elif IS_ENABLED(CONFIG_CC_HAS_OPT_INLINE_MEMSET) > > > > +#define memset_inline(dst, value, size) __builtin_memset(dst, value, size) > > > > +#else > > > > +static inline void *memset_inline(void *dst, int value, size_t size) > > > > +{ > > > > + char *d = dst; > > > > + > > > > + while (size--) > > > > + *d++ = value; > > > > + > > > > + return d; > > > > +} > > > > +#endif > > > > + > > > > > > memset actually returns the original pointer, not the incremented one. > > > Nothing uses the return value of memset_inline here, but it is > > > confusing. > > > > Whoops, good catch, I guess my fingers gave up on those last two > > characters :) I will fix this for v3 once there has been some time for > > further review. > > Do we even need to return a value at all? Might as well just make the > function two lines: > > + for (char *d = dst; size--;) > + *d++ = value; Yeah, good point, no point in returning something that we don't need plus this is basically what we had before, just with a different pointer type. Thanks for the suggestion. > (Technically that could even be one, but maybe that sort of golf loses > clarity. Your choice.) I'll keep it two lines just for the sake of clarity. -- Cheers, Nathan