Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp335632ybv; Wed, 19 Feb 2020 00:22:12 -0800 (PST) X-Google-Smtp-Source: APXvYqxSv0KFgyV+d9jZK9m0UYdG3FcNuJmHrY8+YAe/uIo4Wr8501Qts3gXnbdxxIOy941gqkNT X-Received: by 2002:a9d:bb8:: with SMTP id 53mr17032557oth.150.1582100532310; Wed, 19 Feb 2020 00:22:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582100532; cv=none; d=google.com; s=arc-20160816; b=fhVWZGCKyMFZ1LlVw7+YCdcEdO7YMZBeX7qtVEttZwUnTqHYbSsngypY7BVPo+eXIO LlugCx3JW66+JOv11dA5ZrBM3CPWh+6+Q99ZFFqP0T52+OXQsL+MlXyz3+mWMwH0gkKe h1iRQxiB+8ZLe2RodruCDAIt5R1pN81gVmKm5KWLY7Ag3sH0rXmnC+1KgssJrX+7ncMu 4SFElaf9I5IiJKs2/QN8KBUeDLHdHYHCYduuZvwl10+2DHi9OlI3skAMdp3f/D6bfEpJ hX8lunR5iIixv+3caCUVBoeKYrAagrLPDRUNacJslGgHcRjUdGhaf617Wtd482TBieqe lkDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=qHw7HSs8FE767P6k4EsiiKkzlSU1+4y80L59F2qTuEQ=; b=KA0vQwVbIQeHoexwrEs6TKC+Iu1E6j9TQaVKAiNZgOoy54jGIebgu/BMAqFBrb5WC0 E7+Htk4DHuwWHtDIlcq9mWWDG8R+ikqm7LrenlpK0aeGi7e9Tm4jZXp7F2RJbmdInjEH gfsEZZhnhc6bCtzfe835/QGuT937VfSp9HJ47+Ig/hby+ySdBD61nlBr02At3xklqojc VIkEdwzv530Er8GFg2yhXRytxeukee+ztoDVCJBSzXsSmFXkJ030TRng9m377fKcBF1s g5PhtaQc0MMCdJUIPvyxWuZiMifhvz0VOYjOhBk9Xvh+0rFy8yvOR2krCAdEefqeQnrK P+GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=lcwepjZP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v18si756771otq.209.2020.02.19.00.21.59; Wed, 19 Feb 2020 00:22:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=lcwepjZP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726648AbgBSIUt (ORCPT + 99 others); Wed, 19 Feb 2020 03:20:49 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:46221 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726484AbgBSIUt (ORCPT ); Wed, 19 Feb 2020 03:20:49 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 48MqZw693hz9v6Tr; Wed, 19 Feb 2020 08:48:08 +0100 (CET) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=lcwepjZP; dkim-adsp=pass; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id 77g506B4pZUy; Wed, 19 Feb 2020 08:48:08 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 48MqZw4QHkz9v6Tq; Wed, 19 Feb 2020 08:48:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1582098488; bh=qHw7HSs8FE767P6k4EsiiKkzlSU1+4y80L59F2qTuEQ=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=lcwepjZP7ARYfzBVnUEm8aptYTOR/KMHXp3O7whzA41XCjgXWguuUyWf60KNGzYpj oROaubwS61tyRrTr71vmEKAZwI/y+1ySOJG4BIV9P7PufstXX6b1dZlxinM9yoNGNy pGNDrNmiSSKrtFpc1iZxsmSh/ohtWO6XlK4etj5o= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 685F58B827; Wed, 19 Feb 2020 08:48:09 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id 8fjtfNxb987m; Wed, 19 Feb 2020 08:48:09 +0100 (CET) Received: from [172.25.230.102] (unknown [172.25.230.102]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 2EE6C8B756; Wed, 19 Feb 2020 08:48:09 +0100 (CET) Subject: Re: [PATCH 1/2] powerpc/kprobes: Remove redundant code To: "Naveen N. Rao" , Benjamin Herrenschmidt , Michael Ellerman , Paul Mackerras Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org References: <642c8b4ca59e658be38d8dde00f994e183790a6a.1581687838.git.christophe.leroy@c-s.fr> <1582036611.9hm2t8ijhz.naveen@linux.ibm.com> From: Christophe Leroy Message-ID: <0fc8e46e-968b-c779-0721-03bb0ba0c33c@c-s.fr> Date: Wed, 19 Feb 2020 08:48:09 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <1582036611.9hm2t8ijhz.naveen@linux.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 18/02/2020 à 15:39, Naveen N. Rao a écrit : > Christophe Leroy wrote: >> At the time being we have something like >> >>     if (something) { >>         p = get(); >>         if (p) { >>             if (something_wrong) >>                 goto out; >>             ... >>             return; >>         } else if (a != b) { >>             if (some_error) >>                 goto out; >>             ... >>         } >>         goto out; >>     } >>     p = get(); >>     if (!p) { >>         if (a != b) { >>             if (some_error) >>                 goto out; >>             ... >>         } >>         goto out; >>     } >> >> This is similar to >> >>     p = get(); >>     if (something) { >>         if (p) { >>             if (something_wrong) >>                 goto out; >>             ... >>             return; >>         } >>     } >>     if (!p) { >>         if (a != b) { >>             if (some_error) >>                 goto out; >>             ... >>         } >>         goto out; >>     } >> >> Signed-off-by: Christophe Leroy >> --- >>  arch/powerpc/kernel/kprobes.c | 15 +-------------- >>  1 file changed, 1 insertion(+), 14 deletions(-) > > Good cleanup, thanks. > >> >> diff --git a/arch/powerpc/kernel/kprobes.c >> b/arch/powerpc/kernel/kprobes.c >> index f8b848aa65bd..7a925eb76ec0 100644 >> --- a/arch/powerpc/kernel/kprobes.c >> +++ b/arch/powerpc/kernel/kprobes.c >> @@ -276,8 +276,8 @@ int kprobe_handler(struct pt_regs *regs) >>      kcb = get_kprobe_ctlblk(); >> >>      /* Check we're not actually recursing */ >> +    p = get_kprobe(addr); >>      if (kprobe_running()) { >> -        p = get_kprobe(addr); >>          if (p) { >>              kprobe_opcode_t insn = *p->ainsn.insn; >>              if (kcb->kprobe_status == KPROBE_HIT_SS && >> @@ -308,22 +308,9 @@ int kprobe_handler(struct pt_regs *regs) >>              } >>              prepare_singlestep(p, regs); >>              return 1; >> -        } else if (*addr != BREAKPOINT_INSTRUCTION) { >> -            /* If trap variant, then it belongs not to us */ >> -            kprobe_opcode_t cur_insn = *addr; >> - >> -            if (is_trap(cur_insn)) >> -                goto no_kprobe; >> -            /* The breakpoint instruction was removed by >> -             * another cpu right after we hit, no further >> -             * handling of this interrupt is appropriate >> -             */ >> -            ret = 1; >>          } >> -        goto no_kprobe; > > A minot nit -- removing the above goto makes a slight change to the > logic. But, see my comments for the next patch. All legs of the (p) case are have either a return or a goto, so that goto no_kprobe is limited to the !p case, we have to fall_through now. Christophe