Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751315AbdCQMj4 (ORCPT ); Fri, 17 Mar 2017 08:39:56 -0400 Received: from mail-qt0-f177.google.com ([209.85.216.177]:35590 "EHLO mail-qt0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751022AbdCQMjy (ORCPT ); Fri, 17 Mar 2017 08:39:54 -0400 MIME-Version: 1.0 In-Reply-To: References: <20170317001520.85223-1-md@google.com> <20170317001520.85223-7-md@google.com> <20170317120837.pr74cv3xuj7qpoin@hirez.programming.kicks-ass.net> From: Alexander Potapenko Date: Fri, 17 Mar 2017 13:32:00 +0100 Message-ID: Subject: Re: [PATCH 6/7] md/raid10, LLVM: get rid of variable length array To: Peter Zijlstra Cc: Michael Davidson , Michal Marek , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Herbert Xu , "David S. Miller" , Shaohua Li , Dmitry Vyukov , Matthias Kaehlcke , x86@kernel.org, linux-kbuild@vger.kernel.org, LKML , linux-crypto@vger.kernel.org, linux-raid@vger.kernel.org Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id v2HCe51l006695 Content-Length: 2328 Lines: 66 On Fri, Mar 17, 2017 at 1:31 PM, Alexander Potapenko wrote: > On Fri, Mar 17, 2017 at 1:08 PM, Peter Zijlstra wrote: >> On Thu, Mar 16, 2017 at 05:15:19PM -0700, Michael Davidson wrote: >>> Replace a variable length array in a struct by allocating >>> the memory for the entire struct in a char array on the stack. >>> >>> Signed-off-by: Michael Davidson >>> --- >>> drivers/md/raid10.c | 9 ++++----- >>> 1 file changed, 4 insertions(+), 5 deletions(-) >>> >>> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c >>> index 063c43d83b72..158ebdff782c 100644 >>> --- a/drivers/md/raid10.c >>> +++ b/drivers/md/raid10.c >>> @@ -4654,11 +4654,10 @@ static int handle_reshape_read_error(struct mddev *mddev, >>> /* Use sync reads to get the blocks from somewhere else */ >>> int sectors = r10_bio->sectors; >>> struct r10conf *conf = mddev->private; >>> - struct { >>> - struct r10bio r10_bio; >>> - struct r10dev devs[conf->copies]; >>> - } on_stack; >>> - struct r10bio *r10b = &on_stack.r10_bio; >>> + char on_stack_r10_bio[sizeof(struct r10bio) + >>> + conf->copies * sizeof(struct r10dev)] >>> + __aligned(__alignof__(struct r10bio)); >>> + struct r10bio *r10b = (struct r10bio *)on_stack_r10_bio; >>> int slot = 0; >>> int idx = 0; >>> struct bio_vec *bvec = r10_bio->master_bio->bi_io_vec; >> >> >> That's disgusting. Why not fix LLVM to support this? > > IIUC there's only a handful of VLAIS instances in LLVM code, why not Sorry, "kernel code", not "LLVM code". > just drop them for the sake of better code portability? > (To quote Linus, "this feature is an abomination": > https://lkml.org/lkml/2013/9/23/500) > > -- > Alexander Potapenko > Software Engineer > > Google Germany GmbH > Erika-Mann-Straße, 33 > 80636 München > > Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle > Registergericht und -nummer: Hamburg, HRB 86891 > Sitz der Gesellschaft: Hamburg -- Alexander Potapenko Software Engineer Google Germany GmbH Erika-Mann-Straße, 33 80636 München Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg