From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757851AbcBXSZ2 (ORCPT ); Wed, 24 Feb 2016 13:25:28 -0500 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:25786 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754053AbcBXSZ1 (ORCPT ); Wed, 24 Feb 2016 13:25:27 -0500 Subject: Re: [PATCH] trace-cmd: add trace_hash_find_reverse To: Steven Rostedt References: <1450196004-1899-1-git-send-email-jbacik@fb.com> <20160223172607.5d377d2a@gandalf.local.home> CC: , From: Josef Bacik Message-ID: <56CDF58E.7090307@fb.com> Date: Wed, 24 Feb 2016 13:25:18 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <20160223172607.5d377d2a@gandalf.local.home> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [192.168.54.13] X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-02-24_09:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/23/2016 05:26 PM, Steven Rostedt wrote: > On Tue, 15 Dec 2015 11:13:24 -0500 > Josef Bacik wrote: > >> Sometimes we want to FIFO identical entries in the hash table, so add >> trace_hash_find_reverse, which will cycle through the hash list in reverse. >> This is helpful in our case where we are monitoring block request issues to >> match with their corresponding completes, if we issue multiple times to the same >> block we want to be able to match them with the correct completes (more or less >> anyway). Thanks, >> >> Signed-off-by: Josef Bacik >> --- >> list.h | 5 +++++ >> trace-hash.c | 22 ++++++++++++++++++++++ >> 2 files changed, 27 insertions(+) >> >> diff --git a/list.h b/list.h >> index 9817871..93c64f5 100644 >> --- a/list.h >> +++ b/list.h >> @@ -79,4 +79,9 @@ static inline int list_empty(struct list_head *list) >> &(p)->field != list; \ >> p = n, n = container_of((p)->field.next, typeof(*p), field)) >> >> +#define list_for_each_entry_reverse(p, list, field) \ >> + for (p = container_of((list)->prev, typeof(*p), field); \ >> + &p->field != list; \ >> + p = container_of((p)->field.prev, typeof(*p), field)) >> + >> #endif /* __LIST_H */ >> diff --git a/trace-hash.c b/trace-hash.c >> index 5ffe61c..0dc4f73 100644 >> --- a/trace-hash.c >> +++ b/trace-hash.c >> @@ -94,3 +94,25 @@ trace_hash_find(struct trace_hash *hash, unsigned long long key, >> >> return NULL; >> } >> + >> +struct trace_hash_item * >> +trace_hash_find_reverse(struct trace_hash *hash, unsigned long long key, >> + trace_hash_func match, void *data) >> +{ >> + struct trace_hash_item *item; >> + struct list_head *bucket; >> + int bucket_nr = hash->power ? key & hash->power : >> + key % hash->nr_buckets; >> + >> + bucket = hash->buckets + bucket_nr; >> + list_for_each_entry_reverse(item, bucket, list) { > > Strange, this doesn't compile. > > "struct trace_hash_item has no member named list" > Sorry I sent out the wrong version of this patch. I don't actually need this anymore so you can just drop it. Thanks, Josef