Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7374946ybi; Mon, 22 Jul 2019 12:00:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqztDgQmc4x9BXtVOH05Pbc2OSfHT/bELogON2/PtsE35kVM6jr2W378OVZRYV/zLQO/piiW X-Received: by 2002:a63:c009:: with SMTP id h9mr45613954pgg.166.1563822026318; Mon, 22 Jul 2019 12:00:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563822026; cv=none; d=google.com; s=arc-20160816; b=AQbiU9oBvhaYR7QeDLimRlrg61pnAreXYwXkyzeTS1dzoYUltg+o8n1KlxTNB6baeF n6W9GHfX6qi8R2DeW2vMNQ0icwMkKgONq1+qp14aSZMFnhBkruldeTTr8vexulxTJenz EIjss8CU/7Z0sPenCNClxrEMhSacaFhcUFwfhm+xSkMcFlA+lHL+M8B3Ug3MRRHpeC4g Jk2WX4MVQpk9vzAxMYr6tLDfByFZX2OnbhRntcJAii4CiEN0XJ1C33qWAlDh0JueFs3i en7p+SoD399LPy4vtyHHg3a9Bq66qJt2E1Ok5gnBPKSIPGTGeHq4a3EjOJRLdlfbT5as 1vYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=EOZah5kUC13bHcvzbSgLDufxhi1Qe63umVH2WdpN0zc=; b=qWpOff3luX1ESCSmSxvuYerJVSvZne31KITXj+2PkvCZxxwQ3lo6lF4exakQt86qm7 gjE+XTfnuscjO8+HI3y/k7tksvlSxZHGW3tbLfDnoUuEDXq0rzgpbviwoEFq7q2yiLlJ 88ENm8ONI+jThI9Wz/iEpw4gnkVHYHBRdfg50DYSGAWuX414MXr6ydS266hzdCWj26uG Juu1YKiyofkL4rS9FEHr3i6LFzZd8EZAr7o1h2WyDIBoN3s1lTO3klS5tkMjhOLGfOdB jauYtFGrXGHq/wUb2mGuxxBSVjSXBbKJcGMEHk/QfTwCkk6nGlbTzG0KUuZka9f5X7cl +BBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aol.com header.s=a2048 header.b=DxrhCFr0; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=aol.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x78si9628604pgx.471.2019.07.22.12.00.10; Mon, 22 Jul 2019 12:00:26 -0700 (PDT) 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; dkim=pass header.i=@aol.com header.s=a2048 header.b=DxrhCFr0; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=aol.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729271AbfGVPeI (ORCPT + 99 others); Mon, 22 Jul 2019 11:34:08 -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/z7am8XzmOEhxBQ5CcF7RRdcXbRXHw624852DQZYTJCRmVqL0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XpB4Flt2Htn5O8Jge0sZNuRo mg5qgdLxlPE4BBBuam28749g6L0dJAk2oNUThJaaknYZ_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