Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5601397ybv; Tue, 11 Feb 2020 19:38:32 -0800 (PST) X-Google-Smtp-Source: APXvYqx4Izy6gg08DRO7X2OuNJZKCzaGA7ukZryAXk4+lzGjmaCLTEQIbI+ba+CWG2q1OZLTLXUf X-Received: by 2002:a9d:4e99:: with SMTP id v25mr7959466otk.363.1581478712394; Tue, 11 Feb 2020 19:38:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581478712; cv=none; d=google.com; s=arc-20160816; b=kJ913qZnyEG23R7BmmJruA0DON/my87kBnhyCrWNqRYNPskL4ysU1CPqK6JayVQ1MY oWzNi6BvrMyztIrKEP4PwRGug4GpvfxB8LfGYYQORl8Ynt9qsM83ZB33gre9BXwEy3+7 uCYjT+qxiIhGAGPfmaESB30qG2UxELHITuWEG8EuzeTnhNnPesf2JdoH56m8IMyQKnca sy2WhEHxvZnwvBedXo9lKBfRiM1VCMpFwhsw7ByFBnr0aiHsKxf8Cd69AcgX640QuQTI B1GGAGmfFsoarEuy/Zf68T0F2HlVxMUzjCq3SSMwtq0C6dUGvYbl3J4isF0fjpUReDj+ AOFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=jqjp8DR9BpSBkCVT4AyTGBZkwOJQhZg/XHWI/DKBslQ=; b=0nEkPhw7/bQwEjjlgRmVHuXfDtFXOtNfbY3hN9n8hwME5VdrPsLV3gXUbDvubVUzsZ amZ33tN1wSgoe23RvdbVB6WS/TEkXiMU+gPUuPO1D6Gjjv2YZTmyzvBRO/3PnbL0lNsy D7CwGikWfjy4MGCusGwLsrTREoYxIGvZ8o1E+xb9GSrN040NYs+f7Keext23CTSlR1Es yytWZLI9PI/AxbxQxzDQraHmh7KU4c+gGrmj4szMF9ksVBK6W0RpcXxTHmvDzqt0VU25 Fzf3D/762gKER+3qgXkXv2XNo7mQu6MA0czmTMhjc+0cZoFlnsC98b7I9TE1E+Qcebn2 4pGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kgLuYeSF; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o8si3209841oti.47.2020.02.11.19.38.11; Tue, 11 Feb 2020 19:38:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kgLuYeSF; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-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 S1727710AbgBLDiF (ORCPT + 99 others); Tue, 11 Feb 2020 22:38:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:38648 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727695AbgBLDiF (ORCPT ); Tue, 11 Feb 2020 22:38:05 -0500 Received: from sol.localdomain (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D8E112073C; Wed, 12 Feb 2020 03:38:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581478684; bh=QFEFG/81Rfdx+DhaJa330Iy0plXtvuXYAYlLrbnAw4s=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kgLuYeSFpKxnDdxa83uM8r7H8S2iSSVhydJQbgl1WskDbn0S35JXuXY6oYMb6AFqU HxO5QSmEbAmJQYLuF8FimrMwI0rN+5dYv0mjVwfxsOCEj+bKApbx/sRGflnZL6TTxF hsjxh+dI86q2CbBRmKMiAXqhZqvYy14nr51t/CqE= Date: Tue, 11 Feb 2020 19:38:00 -0800 From: Eric Biggers To: Daniel Rosenberg Cc: Theodore Ts'o , linux-ext4@vger.kernel.org, Jaegeuk Kim , Chao Yu , linux-f2fs-devel@lists.sourceforge.net, linux-fscrypt@vger.kernel.org, Alexander Viro , Richard Weinberger , linux-mtd@lists.infradead.org, Andreas Dilger , Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Gabriel Krisman Bertazi , kernel-team@android.com Subject: Re: [PATCH v7 1/8] unicode: Add utf8_casefold_iter Message-ID: <20200212033800.GC870@sol.localdomain> References: <20200208013552.241832-1-drosen@google.com> <20200208013552.241832-2-drosen@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200208013552.241832-2-drosen@google.com> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Fri, Feb 07, 2020 at 05:35:45PM -0800, Daniel Rosenberg wrote: > This function will allow other uses of unicode to act upon a casefolded > string without needing to allocate their own copy of one. > > The actor function can return an nonzero value to exit early. > > Signed-off-by: Daniel Rosenberg > --- > fs/unicode/utf8-core.c | 25 ++++++++++++++++++++++++- > include/linux/unicode.h | 10 ++++++++++ > 2 files changed, 34 insertions(+), 1 deletion(-) > > diff --git a/fs/unicode/utf8-core.c b/fs/unicode/utf8-core.c > index 2a878b739115d..db050bf59a32b 100644 > --- a/fs/unicode/utf8-core.c > +++ b/fs/unicode/utf8-core.c > @@ -122,9 +122,32 @@ int utf8_casefold(const struct unicode_map *um, const struct qstr *str, > } > return -EINVAL; > } > - > EXPORT_SYMBOL(utf8_casefold); > > +int utf8_casefold_iter(const struct unicode_map *um, const struct qstr *str, > + struct utf8_itr_context *ctx) > +{ > + const struct utf8data *data = utf8nfdicf(um->version); > + struct utf8cursor cur; > + int c; > + int res = 0; > + int pos = 0; > + > + if (utf8ncursor(&cur, data, str->name, str->len) < 0) > + return -EINVAL; > + > + while ((c = utf8byte(&cur))) { > + if (c < 0) > + return c; > + res = ctx->actor(ctx, c, pos); > + pos++; > + if (res) > + return res; > + } > + return res; > +} > +EXPORT_SYMBOL(utf8_casefold_iter); Indirect function calls are expensive these days for various reasons, including Spectre mitigations and CFI. Are you sure it's okay from a performance perspective to make an indirect call for every byte of the pathname? > +typedef int (*utf8_itr_actor_t)(struct utf8_itr_context *, int byte, int pos); The byte argument probably should be 'u8', to avoid confusion about whether it's a byte or a Unicode codepoint. - Eric