From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4D46C76188 for ; Mon, 22 Jul 2019 15:34:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B6E0E2190D for ; Mon, 22 Jul 2019 15:34:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=aol.com header.i=@aol.com header.b="DxrhCFr0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729278AbfGVPeJ (ORCPT ); Mon, 22 Jul 2019 11:34:09 -0400 Received: from sonic315-54.consmr.mail.gq1.yahoo.com ([98.137.65.30]:36971 "EHLO sonic315-54.consmr.mail.gq1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729179AbfGVPeH (ORCPT ); Mon, 22 Jul 2019 11:34:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1563809646; bh=EOZah5kUC13bHcvzbSgLDufxhi1Qe63umVH2WdpN0zc=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From:Subject; b=DxrhCFr0vEoGtuPSEwDUdKRq/z7am8XzmOEhxBQ5CcF7RRdcXbRXHw624852DQZYTJCRmVqL0XFOFwOMQjdmeIeaGqcZNTAd52g7yER4fSvvdjNwvFKqakZlgxliCe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Ak2oNUThJaaknYZ_DTFF_2Qen5KWvrJ26U35FoLa2_idsTT rMG3M5E5Jg1GAZbVJnV7I3am6.KQ41Wn5KU4RitPSg08ZmwGTspQjWAFj.aDrGx0OdIMa02sEqZ8 zumJf7lvMJzZOlfitRgFSD0p0tjWdsqDoPDnIEcUOM4IwN6_6pJYSvnZxeCj9sRyc3y.LR2PfApp 6gxE.YkwFRl5tt7bep8s2idFnrEzKSdUemabNWb3oel3ELwpL38YYblKhnACGk06XBvw9fPdOO.r ly3EY3DVgBCl92GHVbypxGep.W_OJm6q3j.JqzFvMqoQbV_JkPzcNo7PPZZqxrdnUJEwG9pfe5OZ xjnWCXnGGAyHr_eth18VYfXJVcnOiHmBLxiiGDnoo6qnkezzmKh7vSqEXLtvsDGdRwA_pXT0- Received: from sonic.gate.mail.ne1.yahoo.com by sonic315.consmr.mail.gq1.yahoo.com with HTTP; Mon, 22 Jul 2019 15:34:06 +0000 Received: by smtp415.mail.gq1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 7d543092b26e4fc618ecf41b7b8d639f; Mon, 22 Jul 2019 15:34:04 +0000 (UTC) Subject: Re: [PATCH v3 12/24] erofs: introduce tagged pointer To: Steven Rostedt , Amir Goldstein Cc: devel@driverdev.osuosl.org, Stephen Rothwell , Matthew Wilcox , Theodore Ts'o , Will Deacon , Peter Zijlstra , Greg Kroah-Hartman , Miao Xie , linux-erofs@lists.ozlabs.org, LKML , Ingo Molnar , Alexander Viro , linux-fsdevel , Andrew Morton , Linus Torvalds References: <20190722025043.166344-1-gaoxiang25@huawei.com> <20190722025043.166344-13-gaoxiang25@huawei.com> <39fad3ab-c295-5f6f-0a18-324acab2f69e@huawei.com> <20190722104048.463397a0@gandalf.local.home> From: Gao Xiang Message-ID: <0c2cdd4f-8fe7-6084-9c2d-c2e475e6806e@aol.com> Date: Mon, 22 Jul 2019 23:33:53 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190722104048.463397a0@gandalf.local.home> Content-Type: text/plain; charset=gbk Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Steven, On 2019/7/22 ????10:40, Steven Rostedt wrote: >>> and I'm not sure Al could accept __fdget conversion (I just wanted to give a example then...) >>> >>> Therefore, I tend to keep silence and just promote EROFS... some better ideas?... >>> >> Writing example conversion patches to demonstrate cleaner code >> and perhaps reduce LOC seems the best way. > Yes, I would be more interested in seeing patches that clean up the > code than just talking about it. > I guess that is related to me, though I didn't plan to promote a generic tagged pointer implementation in this series... I try to describe what erofs met and my own implementation, assume that we have 3 tagged pointers, a, b, c, and one potential user only (no need to ACCESS_ONCE). One way is #define A_MASK 1 #define B_MASK 1 #define C_MASK 3 /* now we have 3 mask there, A, B, C is simple, the real name could be long... */ void *a; void *b; void *c; /* and some pointers */ In order to decode the tag, we have to ((unsigned long)a & A_MASK) to decode the ptr, we have to ((unsigned long)a & ~A_MASK) In order to fold the tagged pointer... (void *)((unsigned long)a | tag) You can see the only meaning of these masks is the bitlength of tags, but there are many masks (or we have to do open-coded a & 3, if bitlength is changed, we have to fix them all)... therefore my approach is typedef tagptr1_t ta; /* tagptr type a with 1-bit tag */ typedef tagptr1_t tb; /* tagptr type b with 1-bit tag */ typedef tagptr2_t tc; /* tagptr type c with 2-bit tag */ and ta a; tb b; tc c; the type will represent its bitlength of tags and we can use ta, tb, tc to avoid masks or open-coded bitlength. In order to decode the tag, we can tagptr_unfold_tags(a) In order to decode the ptr, we can tagptr_unfold_ptr(a) In order to fold the tagged pointer... a = tagptr_fold(ta, ptr, tag) ACCESS_ONCE stuff is another thing... If my approach seems cleaner, we could move to include/linux later after EROFS stuffs is done... Or I could use a better tagptr approach later if any... Thanks, Gao XIang