From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753581Ab3KGDLY (ORCPT ); Wed, 6 Nov 2013 22:11:24 -0500 Received: from mail-wg0-f50.google.com ([74.125.82.50]:52790 "EHLO mail-wg0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752323Ab3KGDLX (ORCPT ); Wed, 6 Nov 2013 22:11:23 -0500 MIME-Version: 1.0 In-Reply-To: <1383262255.2769.11.camel@joe-AO722> References: <51F73A17.2090208@akamai.com> <1382974150-7392-1-git-send-email-changbin.du@gmail.com> <20131031155253.79a21d6a126be11a64153d8b@linux-foundation.org> <1383262255.2769.11.camel@joe-AO722> Date: Thu, 7 Nov 2013 11:11:21 +0800 Message-ID: Subject: Re: [PATCH v2] dynamic_debug: add wildcard support to filter files/functions/modules From: Changbin Du To: Joe Perches Cc: Andrew Morton , Jason Baron , "linux-kernel@vger.kernel.org list" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2013/11/1 Joe Perches : > On Thu, 2013-10-31 at 15:52 -0700, Andrew Morton wrote: >> On Mon, 28 Oct 2013 23:29:10 +0800 "Du, Changbin" wrote: > [] >> > +/* check if the string matches given pattern which includes wildcards */ >> > +static int match_pattern(const char *pattern, const char *string) > [] >> No, something like this should be in lib/ so that other callers can use >> it. We already have at least one copy handy in >> drivers/ata/libata-core.c:glob_match(). A better approach would be to >> move that glob_match() into lib/glob_match.c then teach dynamic_debug >> to use it. >> >> There are probably other private globbing functions lying around the >> kernel, but it's rather a hard thing to grep for... > > Maybe use lib/parser.c where the other match_ functions > are already. match_ functions in lib/parser.c just do simple match, they doesn't support wildcards. So it's not useful for us. > > match_glob has the disadvantage that it's recursive too. > As you mentioned before, we cannot use it since strings are given from userspace. :) > trace has: > > kernel/trace/trace_events_filter.c:static int regex_match_full(char *str, struct regex *r, int len) > kernel/trace/trace_events_filter.c:static int regex_match_front(char *str, struct regex *r, int len) > kernel/trace/trace_events_filter.c:static int regex_match_middle(char *str, struct regex *r, int len) > kernel/trace/trace_events_filter.c:static int regex_match_end(char *str, struct regex *r, int len) > > but there probably aren't many more that could be converted. Trace filter support wildcards, but it seems the match algorithm couples with trace code. I'll try to see if it can be split.