From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752082AbcIDEew (ORCPT ); Sun, 4 Sep 2016 00:34:52 -0400 Received: from mout.web.de ([212.227.15.4]:64130 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750729AbcIDEeu (ORCPT ); Sun, 4 Sep 2016 00:34:50 -0400 Subject: Re: [PATCH 2/4] sparc: bpf_jit: Move four assignments in bpf_jit_compile() To: Julian Calaby References: <566ABCD9.1060404@users.sourceforge.net> <2179bf7c-9878-adf7-da97-2746d5aa3d34@users.sourceforge.net> Cc: sparclinux , Adam Buchbinder , Alexei Starovoitov , Daniel Borkmann , "David S. Miller" , Rabin Vincent , LKML , kernel-janitors , Julia Lawall , Paolo Bonzini From: SF Markus Elfring Message-ID: Date: Sun, 4 Sep 2016 06:33:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:EkQ+a3fSVdbu3slgcV0O9fmTbCX943OkcmZdt7HRjQqGpr5QUaU wbEtBWealErXXa3WKWmhw4d4RGNl0k2rT/03ApNKxgrQ9KqPRCTkn/zLeKFQ9eXi4Un/oNY 9PZ5HXknmDfPKRfzVOJQcRFPSyP4X+vyHZBob8modtjAuVvl0WJFT80mBSMoaWtgWbWVxAe fmvYFUo0ziwPVklCo/Egw== X-UI-Out-Filterresults: notjunk:1;V01:K0:wY8xshuQ0t4=:R1C7Bh3DQ9mGhHjvvJu2gp R54zAxWBS6f1Nz8iaS9UZX0N8RS/z0nO30788YqxPtv/jqmXYuy76WMLliXBxEoRHx2RZnHw1 Pi8lHgNF0G0IMYHBWyOHC5O2EtLa+vfZCodAjov+r8i2ecoVOvIuWpXMYyeOeazyTOjUztcAX wh2T10K6Yil9cKGTet+xEhS6IzzHQh1TId9Sw4Z1LRh0WgZxWUNuRCf+phTTz47Vht+h3OfBj niRoCEcA7lTk3n49MafLhfpGc0zzW/h6vsOlzZyPZQy7+wtuq7lqEs9dK9UVRoihBEpCxaorG du8NrCM9sRZQO83Z3G35CUxgoGin0o+f8GqJFgnAcn7uC7muH5zImvQ02qlbAkHxSXIGILI5D lSHmh0mlbwYguWp8AVAlTz77eamSE1wf22J/2KCpHfQf5KR9KOhe2GZw8XTLZuoYjH4Zev72I doryjxzEEcaY4SdsbefO0W6ZrVsY3oNnYWPc1YXw8w/Mm0eqZoogrhAdaJgstHKmx1kB3opiU G0bsiHsqNRmDQzKND5i9uEthvx0KwXBJ2V7BuWAiYdnLotZ40V4/RbRFvWQhtMxJnBbcxOpKh TtnEvSuB9t8SUwYYZGZzhmIoCbqDbbHekgYMdD2mTzCoylYrzxsJXU+164CrSxbLl6sK9PyKP 8bQ9rv3C2QJc5IpigqAOM7BEN6QnBpXZV3mBLoUp6z9YQ10Fj3385laNsXMq3JNug5kKg6y2/ Jq/0juOcCsPVaO5MFBoEDrX8pTxYTpL7WdN2NK3o/VDSHcinYrXK6JDoBLppbuOx3JsyRcCVu nNqbTgC Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >> Date: Sat, 3 Sep 2016 17:45:28 +0200 >> >> Move the assignments for four local variables a bit at the beginning >> so that they will only be performed if a corresponding memory allocation >> succeeded by this function. … >> @@ -362,10 +362,10 @@ do { *prog++ = BR_OPC | WDISP22(OFF); \ >> >> void bpf_jit_compile(struct bpf_prog *fp) >> { >> - unsigned int cleanup_addr, proglen, oldproglen = 0; >> - u32 temp[8], *prog, *func, seen = 0, pass; >> - const struct sock_filter *filter = fp->insns; >> - int i, flen = fp->len, pc_ret0 = -1; >> + unsigned int cleanup_addr, proglen, oldproglen; >> + u32 temp[8], *prog, *func, seen, pass; >> + const struct sock_filter *filter; >> + int i, flen = fp->len, pc_ret0; >> unsigned int *addrs; >> void *image; >> >> @@ -385,6 +385,10 @@ void bpf_jit_compile(struct bpf_prog *fp) >> } >> cleanup_addr = proglen; /* epilogue address */ >> image = NULL; >> + filter = fp->insns; >> + oldproglen = 0; >> + pc_ret0 = -1; >> + seen = 0; >> for (pass = 0; pass < 10; pass++) { >> u8 seen_or_pass0 = (pass == 0) ? (SEEN_XREG | SEEN_DATAREF | SEEN_MEM) : seen; … > If you were moving the assignments on declaration onto separate lines > at the top of the file then ok, I see another software design option where the transformation result might be looking more pleasing for you again. > but why all the way down here? * How do you think about the reason I gave in the short commit message? * Are you interested in an other software refactoring instead? http://refactoring.com/catalog/reduceScopeOfVariable.html Would you eventually like to move the source code for this for loop into another function? http://refactoring.com/catalog/extractMethod.html Regards, Markus