Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6673653ybi; Sun, 21 Jul 2019 23:25:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqyfLjg2Fnk3GqAOwfn1CBpxUBnz5LJh4V7/XR06jH7dB7uzaY5jI0/pj/J8l/He39RUo2qc X-Received: by 2002:a17:902:5998:: with SMTP id p24mr72882337pli.110.1563776705982; Sun, 21 Jul 2019 23:25:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563776705; cv=none; d=google.com; s=arc-20160816; b=YWj0ToYRwVA2trWPdmJAdLfqmDZqSXOoOcu/5EbgYoa7RGue5iFG7xiLWqVSGV/RIe EBw37zAGQZ4HAP54UjcFEVDcrROvZfgo2TSwsbnSWsZTyxJI6InHdK3ggHagK+A74Lp6 va8F18h2QrcB2Nubs//IKDbYtEoHWmeBJ1iRlavrf3cNlTcL36Jz8Y/wH+u09WbeK8HB Bx4z6fvHx89q3rxxXypdVtWO0iHFbwvnbN/NgU+SjyIAYZU+3T7+2hYb3OEHX7bExdM7 8J26g0vxnhdMCF1MlxpPDcWIyGfoZ01oTza4mh+hhTNVjUoZQWr4exrfX8ZWeid/OMf7 A/jA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=mRiPNuu0IvHAFpeZVhrWYDUDjsfyID6dmrOBGytJQzY=; b=vYg1YTq69zZqKmVwfPBoGpKM24EH2zT+zvBSdZTedM0maGC1Ab914bWGmKOeKxlQbl 4mQtym2WhN3QMAC1Xz+TDzLaMNFcJ8ZUxf55ET24ykiG057rPiL79VvHeOoUVXL5EEjF W1Qt8/q1K8k7v0xHNcG9GwMdUHnOp7ZtqcD7R01kyDucYbZaTnzNPaZEjeJakJc/l9pD kdIJ4AZljUatcUgm+bMhVGJaeLPI5QEbs/zPTA05pMkTwHGtlpqgktLGQ2xq95m0prrW rcxDHgh/jCmRRo/Nka4usNTkLTN7LK4wQjleJa5ineGU/6Yi8H2HAQE2FchQOghCCuD0 OJTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GiMkqHsb; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w2si6993598plq.414.2019.07.21.23.24.49; Sun, 21 Jul 2019 23:25:05 -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=@gmail.com header.s=20161025 header.b=GiMkqHsb; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727381AbfGVGQf (ORCPT + 99 others); Mon, 22 Jul 2019 02:16:35 -0400 Received: from mail-yb1-f195.google.com ([209.85.219.195]:34318 "EHLO mail-yb1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726139AbfGVGQe (ORCPT ); Mon, 22 Jul 2019 02:16:34 -0400 Received: by mail-yb1-f195.google.com with SMTP id q5so2447553ybp.1; Sun, 21 Jul 2019 23:16:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mRiPNuu0IvHAFpeZVhrWYDUDjsfyID6dmrOBGytJQzY=; b=GiMkqHsb2C/Jw1o6Ub4DsiHZBxr6ZPjhjLrbLjNZ2yaaHCKmZJ1LRjvX1tmJbGD7Bi pKwqIfw1wbCFqysuExvOaGUzgDUJbvojSqnH4QGcuiaNSlyjpp5RKWyyR1HE1O2WkqZi yuolp/P4xNqjATF+LaZi/qhcLf+/MwAI5U2b185js89KVnQ6DBKBKZJAYx134EMcx6zs u2SEuK+hLnumxva+59nzjcpPKHmG1e17rGKrQ3hWlJllBtBmp/5XAu3LQAJRwL9QkU9F h1YP5naXIsNxpmacnONf4p6UavV3n5TqvxfKBQCc5d9fMO2tL1tdauivTwdVkM8E6QnX 6NLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mRiPNuu0IvHAFpeZVhrWYDUDjsfyID6dmrOBGytJQzY=; b=UvJ2h3vq1QZnXVPBWjQX83sg4jGAt3ddU9iy6KdUWzTz6HxfBIVtm18xGZ9qxGa6AM K6nLGyPZb9kOHkMOIu3qpjmDPOd3iMbh5K5Keu6g7yk+3z2c4UmthTGsvHh3Ry8yraX4 e9DG5GpkG1a8Owa5CKFFO/htrvdV+Ls0pGNXP01iqn2r71pFlRa7piMpKw7xMCgJPGKZ OBGf//NjgPVQoQkuJBqOF4sZy7ia5WHtpXm62k9f6SY8Pk4OTCEtFFWKHRvU9Qfr1os6 YbQAdjkf/HqNTVLNxjUBF2kW76HNac9I3scryjrLxlYZPEYWCMPBnB0iuXesJjR6NVxn lS5w== X-Gm-Message-State: APjAAAWooo6IRUfshshHKmx3HhF0tTawlft1JfI3e5jYAqxihzju/pTL 0nygIkLO8Ou8BG/BxTOj3wTJ+XPEQ38U/n1ZTeA= X-Received: by 2002:a25:9a08:: with SMTP id x8mr40685653ybn.439.1563776193646; Sun, 21 Jul 2019 23:16:33 -0700 (PDT) MIME-Version: 1.0 References: <20190722025043.166344-1-gaoxiang25@huawei.com> <20190722025043.166344-13-gaoxiang25@huawei.com> <39fad3ab-c295-5f6f-0a18-324acab2f69e@huawei.com> In-Reply-To: <39fad3ab-c295-5f6f-0a18-324acab2f69e@huawei.com> From: Amir Goldstein Date: Mon, 22 Jul 2019 09:16:22 +0300 Message-ID: Subject: Re: [PATCH v3 12/24] erofs: introduce tagged pointer To: Gao Xiang Cc: Alexander Viro , Greg Kroah-Hartman , Andrew Morton , Stephen Rothwell , "Theodore Ts'o" , Linus Torvalds , linux-fsdevel , devel@driverdev.osuosl.org, LKML , linux-erofs@lists.ozlabs.org, Chao Yu , Miao Xie , Li Guifu , Fang Wei , Steven Rostedt , Ingo Molnar , Matthew Wilcox , Will Deacon , Peter Zijlstra Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 22, 2019 at 8:02 AM Gao Xiang wrote: > > Hi Amir, > > On 2019/7/22 12:39, Amir Goldstein wrote: > > On Mon, Jul 22, 2019 at 5:54 AM Gao Xiang wrote: > >> > >> Currently kernel has scattered tagged pointer usages > >> hacked by hand in plain code, without a unique and > >> portable functionset to highlight the tagged pointer > >> itself and wrap these hacked code in order to clean up > >> all over meaningless magic masks. > >> > >> This patch introduces simple generic methods to fold > >> tags into a pointer integer. Currently it supports > >> the last n bits of the pointer for tags, which can be > >> selected by users. > >> > >> In addition, it will also be used for the upcoming EROFS > >> filesystem, which heavily uses tagged pointer pproach > >> to reduce extra memory allocation. > >> > >> Link: https://en.wikipedia.org/wiki/Tagged_pointer > > > > Well, it won't do much good for other kernel users in fs/erofs/ ;-) > > Thanks for your reply and interest in this patch.... :) > > Sigh... since I'm not sure kernel folks could have some interests in that stuffs. > > Actually at the time once I coded EROFS I found tagged pointer had 2 main advantages: > 1) it saves an extra field; > 2) it can keep the whole stuff atomicly... > And I observed the current kernel uses tagged pointer all around but w/o a proper wrapper... > and EROFS heavily uses tagged pointer... So I made a simple tagged pointer wrapper > to avoid meaningless magic masks and type casts in the code... > > > > > I think now would be a right time to promote this facility to > > include/linux as you initially proposed. > > I don't recall you got any objections. No ACKs either, but I think > > that was the good kind of silence (?) > > Yes, no NAK no ACK...(it seems the ordinary state for all EROFS stuffs... :'( sigh...) > Therefore I decided to leave it in fs/erofs/ in this series... > > > > > You might want to post the __fdget conversion patch [1] as a > > bonus patch on top of your series. > > I am not sure if another potential users could be quite happy with my ("sane?" or not) > implementation... Well, let's ask potential users then. CC kernel/trace maintainers for RB_PAGE_HEAD/RB_PAGE_UPDATE and kernel/locking maintainers for RT_MUTEX_HAS_WAITERS > (Is there some use scenerios in overlayfs and fanotify?...) We had one in overlayfs once. It is gone now. > > 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. Also pointing out that fixing potential bugs in one implementation is preferred to having to patch all copied implementations. I wonder if tagptr_unfold_tags() doesn't need READ_ONCE() as per: 1be5d4fa0af3 locking/rtmutex: Use READ_ONCE() in rt_mutex_owner() rb_list_head() doesn't have READ_ONCE() Nor does hlist_bl_first() and BPF_MAP_PTR(). Are those all safe due to safe call sites? or potentially broken? Thanks, Amir.