Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp673897rwr; Wed, 19 Apr 2023 11:19:30 -0700 (PDT) X-Google-Smtp-Source: AKy350aK+4LXnxbZycT8GqrTNxFDl/eYb/RBfuDXGcfFsIEKTIhm5jNR21cWpVOY34u6+1QXal08 X-Received: by 2002:a17:902:da8b:b0:1a6:be37:22e1 with SMTP id j11-20020a170902da8b00b001a6be3722e1mr7729773plx.15.1681928370549; Wed, 19 Apr 2023 11:19:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681928370; cv=none; d=google.com; s=arc-20160816; b=dch58Jt4UJCIz+pyYLnN1mfgxpGS6Dj4p0FgPFoNZOrmk9/CptbwFjiJTqi/nZLIzI jJfkXHpC1w0aU2dowM4zjCXAh2RqbG8BxQdc6gpStzxNatvXmKBv4aNsnhQflEUz0L69 MvrP/Hqy+Zpzpcmls+HeIIKxjaR0/nga01ZZgrVXuBSCkjzZnEkRXkmMaTuMIk/FIRQ/ nd91mj8F16F2BreLS1bzI/QuHH2hqwz80UiSMRd5iRooVXu6mr97cTcppFaa6oQv8chs GSYySBJiK5KUJ860ohWmHRsTSEKTHgaQo9vrdnYOF6Fid7qQHk2ywAnIRugzCySRaKys 56LA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Ct54S1EPeQeqsM0jzfC6ICg2pSHMQUwFBp/nbEbaGzo=; b=QVSTIA9H7vOwcOeFm7NGSpU4fwiHq0OfRQ/jmnDjxjfcb+u7aleaAwMAO8EfLBli4K l/dOCps4K0y+94bt6yVbjLc/vEYvrx0cIVzqY4baSQqvM0RCwUhGYDC6M3Ok5gHlTFVe y4KOYq3Vxvh4oxgMUPBPo4XIWGrh5ChM+xw74Q3GrJw0z/A9xHXjnyaE4pZfOrVhZK2o J3VLtNked1i0JBR05gXpN7zEsGOT18VBHMjB3RdUKgT+nBk7hToqaqhifMdO10KkRMD/ xjEgHIp/ba3lxkD15g4jg76kn9Dff2oZgvCwX9S5hL60zduSaVpITwJq72iEXmY/POGQ PLbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mttGhr1f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h11-20020a170902b94b00b001a5286ad38esi16285552pls.250.2023.04.19.11.19.18; Wed, 19 Apr 2023 11:19:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mttGhr1f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232525AbjDSSSu (ORCPT + 99 others); Wed, 19 Apr 2023 14:18:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231640AbjDSSS3 (ORCPT ); Wed, 19 Apr 2023 14:18:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45072558A for ; Wed, 19 Apr 2023 11:18:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D780164174 for ; Wed, 19 Apr 2023 18:18:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C89FC433D2; Wed, 19 Apr 2023 18:18:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681928307; bh=vukysRz5NaE4LWG2Afd718xz2x+dfOXM5QhEspRpdV4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mttGhr1fE3I4rQPspXFezgqjHKtEFBHw2zgAsS/d2nixmB8nbZEpr1d8eZELF2LWU hBhV8h3aK/Ni1erlpop8dgsSU0yL+4ZObYry16T8eXE8TXWljLiEZTUS73kdmH+KXO JUeeXS63T0EKBUvm+Yuf3IHrFOqux5kU/nOIAo5IDEdNfWr9VTYeT9/BjAqWTUv8lM 5qWJS/ghcvRK3YDmgq5uknqCQetmV2JxhIXN0dURTP0SgEpv3QnK9I4V77BKrJJe5r CUsE7nRN4dMiByr5/QJqUxjapMkSD7iHlibTHm1243YT3WdqBTMK0x/quopK7qJ86y 5HmA5IoUTp0DA== Date: Wed, 19 Apr 2023 11:18:25 -0700 From: Jaegeuk Kim To: Chao Yu Cc: Wu Bo , linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, wubo.oduw@gmail.com Subject: Re: [PATCH 1/1] f2fs: allocate trace path buffer from names_cache Message-ID: References: <20230414104308.6591-1-bo.wu@vivo.com> <91a05857-c916-cae5-d61d-bbec6f1ae052@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <91a05857-c916-cae5-d61d-bbec6f1ae052@kernel.org> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/19, Chao Yu wrote: > On 2023/4/19 0:07, Jaegeuk Kim wrote: > > On 04/18, Chao Yu wrote: > > > On 2023/4/14 18:43, Wu Bo wrote: > > > > It would be better to use the dedicated slab to store path. > > > > > > > > Signed-off-by: Wu Bo > > > > --- > > > > fs/f2fs/file.c | 4 ++-- > > > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > > > > > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > > > > index 15dabeac4690..27137873958f 100644 > > > > --- a/fs/f2fs/file.c > > > > +++ b/fs/f2fs/file.c > > > > @@ -4361,7 +4361,7 @@ static void f2fs_trace_rw_file_path(struct kiocb *iocb, size_t count, int rw) > > > > struct inode *inode = file_inode(iocb->ki_filp); > > > > char *buf, *path; > > > > - buf = f2fs_kmalloc(F2FS_I_SB(inode), PATH_MAX, GFP_KERNEL); > > > > + buf = __getname(); > > > > > > How about: > > > > > > buf = f2fs_kmem_cache_alloc(names_cachep, GFP_KERNEL, NULL, F2FS_I_SB(inode)); > > > > This looks like a hack using names_cachep? > > names_cachep was exported in fs.h. I think that's for __getname() in general, which doesn't indicate you can hack. No one is using like that. $ grep names_cachep fs/* -R fs/dcache.c:struct kmem_cache *names_cachep __read_mostly; fs/dcache.c:EXPORT_SYMBOL(names_cachep); fs/dcache.c: names_cachep = kmem_cache_create_usercopy("names_cache", PATH_MAX, 0, $ grep __getname fs/* -R fs/ceph/mds_client.c: path = __getname(); fs/cifs/cifsproto.h: return __getname(); fs/dcache.c:/* SLAB cache for __getname() consumers */ fs/d_path.c: char *page = __getname(); fs/exfat/dir.c: nb->lfn = __getname(); fs/f2fs/file.c: buf = __getname(); fs/fat/dir.c: *unicode = __getname(); fs/fat/namei_vfat.c: uname = __getname(); fs/hostfs/hostfs_kern.c: char *name = __getname(); fs/namei.c: result = __getname(); fs/namei.c: result = __getname(); fs/ntfs3/dir.c: name = __getname(); fs/ntfs3/xattr.c: buf = __getname(); fs/ntfs3/inode.c: new_de = __getname(); fs/ntfs3/inode.c: de = __getname(); fs/ntfs3/inode.c: de = __getname(); fs/ntfs3/namei.c: struct cpu_str *uni = __getname(); fs/ntfs3/namei.c: de = __getname(); fs/ntfs3/namei.c: struct cpu_str *uni = __getname(); fs/ntfs3/namei.c: uni = __getname(); fs/ntfs3/namei.c: uni1 = __getname(); fs/vboxsf/utils.c: * Returns a shfl_string allocated through __getname (must be freed using fs/vboxsf/utils.c: buf = __getname(); fs/vboxsf/utils.c: shfl_path = __getname(); > > > Using f2fs_kmem_cache_alloc is able to inject malloc error. > > But here is a trace event, is it ok to inject error in a trace path? > > Yes, the fail path handling is very simple, so it's fine to leave it > as it is. > > Reviewed-by: Chao Yu What is this for? > > Thanks, > > > > > > > > > > if (!buf) > > > > return; > > > > path = dentry_path_raw(file_dentry(iocb->ki_filp), buf, PATH_MAX); > > > > @@ -4374,7 +4374,7 @@ static void f2fs_trace_rw_file_path(struct kiocb *iocb, size_t count, int rw) > > > > trace_f2fs_dataread_start(inode, iocb->ki_pos, count, > > > > current->pid, path, current->comm); > > > > free_buf: > > > > - kfree(buf); > > > > + __putname(buf); > > > > > > kmem_cache_free(names_cachep, buf); > > > > > > Thanks, > > > > > > > } > > > > static ssize_t f2fs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)