Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751847AbbFYDH2 (ORCPT ); Wed, 24 Jun 2015 23:07:28 -0400 Received: from cdptpa-outbound-snat.email.rr.com ([107.14.166.231]:38225 "EHLO cdptpa-oedge-vip.email.rr.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751241AbbFYDHV (ORCPT ); Wed, 24 Jun 2015 23:07:21 -0400 Date: Wed, 24 Jun 2015 23:07:48 -0400 From: Steven Rostedt To: Josef Bacik Cc: , Subject: Re: [PATCH V2] trace-cmd: add option to group like comms for profile Message-ID: <20150624230748.70e088f2@grimm.local.home> In-Reply-To: <1432229408-1479-1-git-send-email-jbacik@fb.com> References: <1432229408-1479-1-git-send-email-jbacik@fb.com> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.25; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-RR-Connecting-IP: 107.14.168.130:25 X-Cloudmark-Score: 0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1631 Lines: 62 On Thu, 21 May 2015 13:30:08 -0400 Josef Bacik wrote: > V1->V2: > -renamed the option to --by-comm, added it to trace-cmd report --profile as well > -fixed up the string hash Or break it ;-) > -changed it to merge all events after the fact so it's less error prone > diff --git a/trace-hash-local.h b/trace-hash-local.h > index 997b11c..eaeeaaf 100644 > --- a/trace-hash-local.h > +++ b/trace-hash-local.h > @@ -48,4 +48,13 @@ static inline unsigned int trace_hash(int val) > return hash; > } > > +static inline unsigned int trace_hash_str(char *str) > +{ > + int val = 0; > + int i; > + > + for (i = 0; str[i]; i++) > + val += ((int)str[i]) << (i & 0xffffff); > + return trace_hash(val); > +} > I need to clean out my medicine cabinet and remove all the expired meds. Because I was definitely taking something nasty when I recommended (i & 0xffffff)! When i is greater than 32 (which is less than 0xffffff) it will overflow the addition. What I wanted was that we don't shift more than 24 bits. Where 2 ** 24 - 1 == 0xffffff. That should be: val += ((int)str[i]) << (i % 25); my bad :-/ To avoid the slow '%', I'll just use '& 0xf', as shifting it 16 times is enough for this algorithm. No need to send a new patch, I'll fix it, as it was my brain fart. I'll review the rest of this patch too and apply it if nothing sticks out. Thanks! -- Steve -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/