Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp293947ybl; Tue, 10 Dec 2019 23:12:51 -0800 (PST) X-Google-Smtp-Source: APXvYqwFsZi9ystwbR0NFHxc+3oGlJrIHxkZb7jzfVFQSnEaMuCQVTIClsUOI6Z/hneSjZzgyzVx X-Received: by 2002:a05:6830:1691:: with SMTP id k17mr1281238otr.282.1576048371064; Tue, 10 Dec 2019 23:12:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576048371; cv=none; d=google.com; s=arc-20160816; b=WePDZsPqKvAHKu4Mug7elWHOdU2zwNjauWTR8mj72ZDQzyw0Wx4XnQoffn6wrheNty ASGpACq5DCRiAsFqYaE2WccArmYwtC4ISoDcHSGedM3xjiovZfQeOzbHC1c2zkGKApac koiVNWEIz2MxXWL1kJSa7GL/B+aVBgfUvkAwuqLHimOZOdieeBFwZZwFYzKQ08XqVnUn u7kfKigqs8LWRxCIElAPSABxuzsHMS6xiDtvQvbZY44tIEjLAONC3FudA0/78jW+unHM l9Qe+Wt4vp8YFUP7FuTvHJsLOKXxER9XtpFxiEg2FM3kqGdQn0EcTXsBLTkE39uFv1M/ PzeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=dSCquZ3imb87SN/cx+i0d8v1B8f41qO3qjgawFgGPxU=; b=vX4Qa/jCh5vIaDSqKRIqW35HCvP4kdBiZKbEX98UmlQFcSPuli4himfc27SsVaWZOZ C4+5DavLVQJPeo1f1m10lMbkHXc/hfSKafFIKgu1n4O5SBPMYWhanNqnE4e3FeWabgjY 4g3lhsKA3ShmNeOR0TATjMOlQd7mNzUXT59jDJAXb9ITdMpmR9vFn4h9OifeDvnJ3iBL ytx8Fl0xq4gDHEP8pptsYmvVHmMDpMgJniHpTzk0vo4PLP6sJQYl9kK9gwh/rtUpwLx3 3XTErKljke1di1Dv5DG3YE1/HXVzkgwi+8MYI3PURD2k5S7J/H6Il+eNs0IfMNzXAA9Z KznA== 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 s74si604959oie.109.2019.12.10.23.12.38; Tue, 10 Dec 2019 23:12:51 -0800 (PST) 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 S1727901AbfLKHMI (ORCPT + 99 others); Wed, 11 Dec 2019 02:12:08 -0500 Received: from szxga08-in.huawei.com ([45.249.212.255]:42522 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726487AbfLKHMI (ORCPT ); Wed, 11 Dec 2019 02:12:08 -0500 Received: from DGGEMM403-HUB.china.huawei.com (unknown [172.30.72.56]) by Forcepoint Email with ESMTP id 4ACD0B87F982C67764B5; Wed, 11 Dec 2019 15:12:02 +0800 (CST) Received: from dggeme762-chm.china.huawei.com (10.3.19.108) by DGGEMM403-HUB.china.huawei.com (10.3.20.211) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 11 Dec 2019 15:12:01 +0800 Received: from architecture4 (10.160.196.180) by dggeme762-chm.china.huawei.com (10.3.19.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Wed, 11 Dec 2019 15:12:01 +0800 Date: Wed, 11 Dec 2019 15:17:11 +0800 From: Gao Xiang To: Tiezhu Yang CC: Al Viro , Eric Biggers , Matthew Wilcox , "Theodore Y. Ts'o" , Jaegeuk Kim , Chao Yu , Tyler Hicks , , , , , , "Darrick J. Wong" Subject: Re: [PATCH v5] fs: introduce is_dot_or_dotdot helper for cleanup Message-ID: <20191211071711.GA231266@architecture4> References: <1576030801-8609-1-git-send-email-yangtiezhu@loongson.cn> <20191211024858.GB732@sol.localdomain> <20191211044723.GC4203@ZenIV.linux.org.uk> <4a90aaa9-18c8-f0a7-19e4-1c5bd5915a28@loongson.cn> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <4a90aaa9-18c8-f0a7-19e4-1c5bd5915a28@loongson.cn> User-Agent: Mutt/1.9.4 (2018-02-28) X-Originating-IP: [10.160.196.180] X-ClientProxiedBy: dggeme715-chm.china.huawei.com (10.1.199.111) To dggeme762-chm.china.huawei.com (10.3.19.108) X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 11, 2019 at 02:38:34PM +0800, Tiezhu Yang wrote: > On 12/11/2019 12:47 PM, Al Viro wrote: > > On Wed, Dec 11, 2019 at 11:59:40AM +0800, Tiezhu Yang wrote: > > > > > static inline bool is_dot_or_dotdot(const unsigned char *name, size_t len) > > > { > > > if (len == 1 && name[0] == '.') > > > return true; > > > > > > if (len == 2 && name[0] == '.' && name[1] == '.') > > > return true; > > > > > > return false; > > > } > > > > > > Hi Matthew, > > > > > > How do you think? I think the performance influence is very small > > > due to is_dot_or_dotdot() is a such short static inline function. > > It's a very short inline function called on a very hot codepath. > > Often. > > > > I mean it - it's done literally for every pathname component of > > every pathname passed to a syscall. > > OK. I understand. Let us do not use the helper function in fs/namei.c, > just use the following implementation for other callers: > > static inline bool is_dot_or_dotdot(const unsigned char *name, size_t len) > { > if (len >= 1 && unlikely(name[0] == '.')) { And I suggest drop "unlikely" here since files start with prefix '.' (plus specical ".", "..") are not as uncommon as you expected... Thanks, Gao Xiang > if (len < 2 || (len == 2 && name[1] == '.')) > return true; > } > > return false; > } > > Special thanks for Matthew, Darrick, Al and Eric. > If you have any more suggestion, please let me know. > > Thanks, > > Tiezhu Yang >