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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 68BB9C4320A for ; Mon, 23 Aug 2021 12:14:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 524DB613B3 for ; Mon, 23 Aug 2021 12:14:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235891AbhHWMPW (ORCPT ); Mon, 23 Aug 2021 08:15:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236972AbhHWMPT (ORCPT ); Mon, 23 Aug 2021 08:15:19 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01F95C061152 for ; Mon, 23 Aug 2021 05:13:56 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id o10so10086934plg.0 for ; Mon, 23 Aug 2021 05:13:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=USD5OFknfQfTTpEURTjZ0WrHVrtGhEjlaRPsgw1f+QE=; b=vo8MOmKcUWIsLMfw5yQwAqFC5pN/iVnhcnEJibUyh0i31ox9NIt/BXe8Y4RoxpXIM3 Cz3h2wPLXFnWY49bz6JhAOvaNezU6BOoqZ4U24k2Y5sBm/az7WAJi3ugoWTFzA3MkZGV DM9Vzs62DIVfiivf7wEvYLe60k1JW4kJroPlAHRE5zqXxE1mMUmOTBLmsXk1ZfX5TN+Z /kLQgLkjiIvt/7iipOdzyeY9jn6iWzvSz6dnUVRv8G7VgfcmA34XC0DIn+BVWfN4gWAJ KhVZo98NG+NHYz1F0SFSgy3+c3ouvnDwopWONF0u+si8JeBfaxDs6eopmJjY+2zaIFvu virQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=USD5OFknfQfTTpEURTjZ0WrHVrtGhEjlaRPsgw1f+QE=; b=HNEEycP6ovQFhWWW8+F0JGdCn88JBgsLXppslsh5ZZLo1eCkvRA10YW9DKlWEG6Oi0 CxUu6ginX+59Xe4/zzJ4oFrkChQ3d8Eo0AyvYo/41eqz2VnuuURp0GVM6pxens0KfsEW Ip1txbnH+TiSAwnI7LMWzcB+Y3Fy7EiHmpY4uNaL/Q+cRtSzYmgV1aNH3mgur/bdlaB1 ETdFrPDAgaPJeubxeXgDOZYWaLAVUNJxK5JE43K182Y9TMM8qsNYd+pJ4hda7kbSS5yW yTwWePOCgRX3x00nQ3cRLaFt0xizW8xZ7qskbfokissrMROx9glogX6fuPCjxffPODXN Pn0w== X-Gm-Message-State: AOAM533n9Bt26zWjrOWGeoonz5VpRC/P+2yYBS9G2HcYLKL14ZACs8qt qHehpoSYDkfF0DO6wuSiE7mlZw== X-Google-Smtp-Source: ABdhPJyNUbHpBwjyvMydx8DGbGbM8fWE1CehelWG1WvHoJPE237bsM++fPdTwPOlRbyrtdvtEU7sOw== X-Received: by 2002:a17:902:76cb:b029:12b:2fb8:7c35 with SMTP id j11-20020a17090276cbb029012b2fb87c35mr28087072plt.16.1629720835386; Mon, 23 Aug 2021 05:13:55 -0700 (PDT) Received: from leoy-ThinkPad-X240s ([202.155.204.36]) by smtp.gmail.com with ESMTPSA id w8sm16336627pjd.55.2021.08.23.05.13.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Aug 2021 05:13:54 -0700 (PDT) Date: Mon, 23 Aug 2021 20:13:48 +0800 From: Leo Yan To: James Clark Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo , Peter Zijlstra , Adrian Hunter , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Will Deacon , Russell King , Catalin Marinas , Mathieu Poirier , Suzuki K Poulose , Mike Leach , John Garry , Andi Kleen , Riccardo Mancini , Jin Yao , Li Huafei , coresight@lists.linaro.org Subject: Re: [PATCH v1 2/3] perf auxtrace: Add compat_auxtrace_mmap__{read_head|write_tail} Message-ID: <20210823121348.GE100516@leoy-ThinkPad-X240s> References: <20210809112727.596876-1-leo.yan@linaro.org> <20210809112727.596876-3-leo.yan@linaro.org> <2b4e0c07-a8df-cca6-6a94-328560f4b0c6@arm.com> <20210823095155.GC100516@leoy-ThinkPad-X240s> <319ee11a-06f7-abde-6495-d2175928b9fe@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <319ee11a-06f7-abde-6495-d2175928b9fe@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 23, 2021 at 11:57:52AM +0100, James Clark wrote: [...] > Ok thanks for the explanation, that makes sense now. I do have one other > point about the documentation for the function: Welcome! > > + * When update the AUX tail and detects any carrying in the high 32 bits, it > > + * means there have two store operations in user space and it cannot promise > > + * the atomicity for 64-bit write, so return '-1' in this case to tell the > > + * caller an overflow error has happened. > > + */ > > I couldn't see how it can ever return -1, it seems like it would loop forever > until it reads the correct value. I use this chunk comment to address the function compat_auxtrace_mmap__write_tail(): +int __weak compat_auxtrace_mmap__write_tail(struct auxtrace_mmap *mm, u64 tail) +{ + struct perf_event_mmap_page *pc = mm->userpg; + u64 mask = (u64)(UINT32_MAX) << 32; + + if (tail & mask) + return -1; + + /* Ensure all reads are done before we write the tail out */ + smp_mb(); + WRITE_ONCE(pc->aux_tail, tail); + return 0; +} Please let me know if this is okay or not? Otherwise, if you think the format can cause confusion, I'd like to split the comments into two sections, one section for reading AUX head and another is for writing AUX tail. Thanks, Leo 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=-4.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 AD4B0C4338F for ; Mon, 23 Aug 2021 12:16:34 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7A97161184 for ; Mon, 23 Aug 2021 12:16:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7A97161184 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vQ9nlROJQXuWQkKAZmBBiG6scfPT3d7s7qBKFY4QyZ8=; b=yR5gv9tZ/geUeA mY7TIAT3I8kroEXuAWSRuCCdDdOvpkO3Ni1qFhzGGoTMgsyaMOVYdCK58gva9YEB9c+u0RIvNPJRO CRc751MtLhJPNlU4/agpSXkUsgpzgIGzPAty1xpSfuGD7mFfc5Fvct7GEBIYSVRUCCYUQb/U4fXNV czh8S0VgyHb3++kUoDknRLk0AfuSPHApL/cfJ99fQ07JpjR4ZwucTpPbiJq+4KMwbUPLvF8TOr/5g 2YxrEYpjD71kCdfdjuykyGuVrWAKTdWVnV/1tEtAsqVHY6d/h/i3p2jpSCs3D47ceJacsJfIRBmrV L9c9F7KwpGyQUmWpOxMA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mI8qC-00GiVE-UK; Mon, 23 Aug 2021 12:14:13 +0000 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mI8q6-00GiQh-ON for linux-arm-kernel@lists.infradead.org; Mon, 23 Aug 2021 12:14:10 +0000 Received: by mail-pl1-x62d.google.com with SMTP id o10so10086933plg.0 for ; Mon, 23 Aug 2021 05:13:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=USD5OFknfQfTTpEURTjZ0WrHVrtGhEjlaRPsgw1f+QE=; b=vo8MOmKcUWIsLMfw5yQwAqFC5pN/iVnhcnEJibUyh0i31ox9NIt/BXe8Y4RoxpXIM3 Cz3h2wPLXFnWY49bz6JhAOvaNezU6BOoqZ4U24k2Y5sBm/az7WAJi3ugoWTFzA3MkZGV DM9Vzs62DIVfiivf7wEvYLe60k1JW4kJroPlAHRE5zqXxE1mMUmOTBLmsXk1ZfX5TN+Z /kLQgLkjiIvt/7iipOdzyeY9jn6iWzvSz6dnUVRv8G7VgfcmA34XC0DIn+BVWfN4gWAJ KhVZo98NG+NHYz1F0SFSgy3+c3ouvnDwopWONF0u+si8JeBfaxDs6eopmJjY+2zaIFvu virQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=USD5OFknfQfTTpEURTjZ0WrHVrtGhEjlaRPsgw1f+QE=; b=bNL6yFKHGShFco1JsAM01y15hGyCJECWhWWZbdPijXHq1zGh4GEfVWR0r91lX6wXR4 NLlMWHtfmY/o04SlCiaCXHAUxjvYRKT2/CYAgUvY+CDua9gVXHXMTdxCs8WCHGHiIpNW WbCyqbLObS51+4ZqrTKvdhCFVrHcroR+yorwwlNjOWqH7BpFjyg6NeMWS7eGk6CcHs85 QwbNwayjKucJfv7JkAkLWQPSMnwH5ZwJQVcp4N7/Hkn78uEue1S0wboJpxW3ag7kzXVB 8nZ79wBk3M96XYQBKKJv6K024Y8gEpSQ1wewEiaKD/xf1Ot81vB4ekEA1fJ161vxQC6y 1kog== X-Gm-Message-State: AOAM531cZmwCBPAN9NuWNOaWz84cCVLr6J4eXoiS3z8BhYsWLtSjfgz/ 1ilZTXEctG3NV25fRXfLWT3Y+Q== X-Google-Smtp-Source: ABdhPJyNUbHpBwjyvMydx8DGbGbM8fWE1CehelWG1WvHoJPE237bsM++fPdTwPOlRbyrtdvtEU7sOw== X-Received: by 2002:a17:902:76cb:b029:12b:2fb8:7c35 with SMTP id j11-20020a17090276cbb029012b2fb87c35mr28087072plt.16.1629720835386; Mon, 23 Aug 2021 05:13:55 -0700 (PDT) Received: from leoy-ThinkPad-X240s ([202.155.204.36]) by smtp.gmail.com with ESMTPSA id w8sm16336627pjd.55.2021.08.23.05.13.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Aug 2021 05:13:54 -0700 (PDT) Date: Mon, 23 Aug 2021 20:13:48 +0800 From: Leo Yan To: James Clark Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo , Peter Zijlstra , Adrian Hunter , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Will Deacon , Russell King , Catalin Marinas , Mathieu Poirier , Suzuki K Poulose , Mike Leach , John Garry , Andi Kleen , Riccardo Mancini , Jin Yao , Li Huafei , coresight@lists.linaro.org Subject: Re: [PATCH v1 2/3] perf auxtrace: Add compat_auxtrace_mmap__{read_head|write_tail} Message-ID: <20210823121348.GE100516@leoy-ThinkPad-X240s> References: <20210809112727.596876-1-leo.yan@linaro.org> <20210809112727.596876-3-leo.yan@linaro.org> <2b4e0c07-a8df-cca6-6a94-328560f4b0c6@arm.com> <20210823095155.GC100516@leoy-ThinkPad-X240s> <319ee11a-06f7-abde-6495-d2175928b9fe@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <319ee11a-06f7-abde-6495-d2175928b9fe@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210823_051406_902098_3A75F09A X-CRM114-Status: GOOD ( 20.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Aug 23, 2021 at 11:57:52AM +0100, James Clark wrote: [...] > Ok thanks for the explanation, that makes sense now. I do have one other > point about the documentation for the function: Welcome! > > + * When update the AUX tail and detects any carrying in the high 32 bits, it > > + * means there have two store operations in user space and it cannot promise > > + * the atomicity for 64-bit write, so return '-1' in this case to tell the > > + * caller an overflow error has happened. > > + */ > > I couldn't see how it can ever return -1, it seems like it would loop forever > until it reads the correct value. I use this chunk comment to address the function compat_auxtrace_mmap__write_tail(): +int __weak compat_auxtrace_mmap__write_tail(struct auxtrace_mmap *mm, u64 tail) +{ + struct perf_event_mmap_page *pc = mm->userpg; + u64 mask = (u64)(UINT32_MAX) << 32; + + if (tail & mask) + return -1; + + /* Ensure all reads are done before we write the tail out */ + smp_mb(); + WRITE_ONCE(pc->aux_tail, tail); + return 0; +} Please let me know if this is okay or not? Otherwise, if you think the format can cause confusion, I'd like to split the comments into two sections, one section for reading AUX head and another is for writing AUX tail. Thanks, Leo _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel