Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp509729imm; Wed, 1 Aug 2018 00:06:00 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcmtRaLmc/DcLqYP+8HTsZgh1okKqpV7QB2ktfBRSiQ/sps8xLFAxNp10zoEWZc9qkgB4ZH X-Received: by 2002:a62:cc4d:: with SMTP id a74-v6mr25701596pfg.200.1533107160158; Wed, 01 Aug 2018 00:06:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533107160; cv=none; d=google.com; s=arc-20160816; b=n1BHZcd1nArlluU1AoRtZA293/lXfAxBpEEykXtbtv0eMWH32kHb0cjLTZSoBZuct4 lavBnQrO1zyI/jTTZ0TWUcn8NZfmqdDYco3Yu4Foy/InB579oJ40l9dSjF223kxGZ22U 4mfZAhFhY4yYmU0DCCQlPV0AHRKt1PP10idNhqeRERs2HcweJGmoUzT4FSqiJi45PoSB G6aPetiv7XG8oyLs9o7ZalgOH5DEKZHIJuLhKvoOIdI4N8t+Zq0+2rmw1A2DfCA3ZS1F g1dj+AR/G9SzI+X6ZSU2ZyaGX+CObh4wfOErk88aXxJeYm7e31ymv057Lp8pJfUirEwg giuw== 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:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=jJttFK961YhogSkApHVjAtKhyrGaVR65CQTgjlzBuNE=; b=z+BsQSEbfuObHGYP0Hn67KLXr9d1yjOY2IhIxLCrrs89Xey3iYBoRcLHtiDaSHGyFO PhmnBaHvt5lVd7dDUCsIyFPxpsur6IMxhgHgzjzbabQY17f721Q0LIui05GsX6Y7keWf 4i4aNm5oycx49+lQdfDapVMjoBftjho/+WUE2YYxGSmNM5PVUrELfxZZvHGr48mFyrkc CrtCkvOx4IVOXbJyB6S/S2HGprsmy+w/RvlCIVbMUlkbPDq2gU2Mlr6LQcwhQvYZMjY/ deCXYWpsLbFf8OPEBiB3vQLtR+8z4D5iwGxOCfvIFjFg5eAa6eJc02F2UWnFVcrp7W4J XtkQ== ARC-Authentication-Results: i=1; mx.google.com; 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 33-v6si14530333plc.205.2018.08.01.00.05.45; Wed, 01 Aug 2018 00:06:00 -0700 (PDT) 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; 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 S2387540AbeHAIsI (ORCPT + 99 others); Wed, 1 Aug 2018 04:48:08 -0400 Received: from smtprelay0235.hostedemail.com ([216.40.44.235]:56177 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387445AbeHAIsI (ORCPT ); Wed, 1 Aug 2018 04:48:08 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay06.hostedemail.com (Postfix) with ESMTP id 0799C18229425; Wed, 1 Aug 2018 07:03:56 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 50,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::::::::::::::::::,RULES_HIT:41:355:379:541:599:967:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:1963:2198:2199:2393:2525:2560:2563:2682:2685:2828:2859:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:3870:3871:3872:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4250:4321:5007:6742:7903:9025:10004:10400:10848:11026:11232:11658:11914:12043:12438:12555:12679:12740:12895:12986:13069:13095:13311:13357:13439:13894:14096:14097:14181:14659:14721:21080:21433:21451:21611:21627:21740:30012:30029:30054:30091,0,RBL:47.151.153.53:@perches.com:.lbl8.mailshell.net-62.14.0.100 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: flock12_4ae2e3065c08 X-Filterd-Recvd-Size: 3344 Received: from XPS-9350.home (unknown [47.151.153.53]) (Authenticated sender: joe@perches.com) by omf09.hostedemail.com (Postfix) with ESMTPA; Wed, 1 Aug 2018 07:03:52 +0000 (UTC) Message-ID: Subject: Re: [PATCH v3 5/9] powerpc/traps: Print signal name for unhandled signals From: Joe Perches To: Christophe LEROY , Murilo Opsfelder Araujo , linux-kernel@vger.kernel.org Cc: Alastair D'Silva , Andrew Donnellan , Balbir Singh , Benjamin Herrenschmidt , Cyril Bur , "Eric W . Biederman" , Michael Ellerman , Michael Neuling , Nicholas Piggin , Paul Mackerras , Simon Guo , Sukadev Bhattiprolu , "Tobin C . Harding" , linuxppc-dev@lists.ozlabs.org Date: Wed, 01 Aug 2018 00:03:50 -0700 In-Reply-To: <631e9a9b-dbbe-ede7-eb81-81520cc36ad5@c-s.fr> References: <20180731145020.14009-1-muriloo@linux.ibm.com> <20180731145020.14009-6-muriloo@linux.ibm.com> <631e9a9b-dbbe-ede7-eb81-81520cc36ad5@c-s.fr> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.28.1-2 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2018-08-01 at 08:37 +0200, Christophe LEROY wrote: > Le 31/07/2018 ? 16:50, Murilo Opsfelder Araujo a ?crit : > > This adds a human-readable name in the unhandled signal message. > > Before this patch, a page fault looked like: > > pandafault[6303]: unhandled signal 11 at 100007d0 nip 1000061c lr 7fff93c55100 code 2 in pandafault[10000000+10000] > > After this patch, a page fault looks like: > > pandafault[6352]: segfault (11) at 13a2a09f8 nip 13a2a086c lr 7fffb63e5100 code 2 in pandafault[13a2a0000+10000] ]] > > diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c [] > > @@ -96,6 +96,41 @@ EXPORT_SYMBOL(__debugger_fault_handler); > > #define TM_DEBUG(x...) do { } while(0) > > #endif > > > > +static const char *signames[SIGRTMIN + 1] = { > > + "UNKNOWN", > > + "SIGHUP", // 1 > > + "SIGINT", // 2 [] > I don't think is is worth having that full table when we only use a few > of them. (As discussed in v1 https://patchwork.ozlabs.org/patch/948802/) > > I would suggest to instead use a function like this: > > static const char *signame(int signr) > { > if (signr == SIGBUS) > return "bus error"; > if (signr == SIGFPE) > return "floating point exception"; > if (signr == SIGILL) > return "illegal instruction"; > if (signr == SIGILL) > return "segfault"; > if (signr == SIGTRAP) > return "unhandled trap"; > return "unknown signal"; > } trivia: Unless the if tests are ordered most to least likely, perhaps it would be better to use a switch/case and let the compiler decide. switch (signr) { case SIGBUS: return "bus error"; case SIGFPE: return "floating point exception"; case SIGILL: return "illegal instruction"; case SIGSEGV: return "segfault"; case SIGTRAP: return "unhandled trap"; } return "unknown signal"; }