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=-8.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 10236C4338F for ; Mon, 23 Aug 2021 16:03:20 +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 CDFB1613D2 for ; Mon, 23 Aug 2021 16:03:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CDFB1613D2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com 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:Date: Message-ID:From:References:Cc:To:Subject:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=CyHmXHbO9BggS+jQ+SNkmEgye7J2t0jM0FmpWKdHv70=; b=PNRF5Zra1zrajz3c6OeYxeNTmu sTm87HbfdNEZTq14czOHA7NvrwfPpIl3vRiF6yyzjGBoq/C/fLOjZxG6nj+bcXkIq2+UnGGm0m+If FxTSzCzjl8Kl9yl6VPW5hP9M3blp69PwYQLxiLnGi8MnQC+wEN32hlYnKBaoNIkaYfIB5qYsDY+0q WRHjM2wZ5TGLOStEcBWsBE9XUOju2eGxdG23+AJq5KftmTTT+SwddBofzVHwnyz292DthvkxOtszA vMV+JgshKskrH4EY3lcyFbT0Q5ko+5krNHEvkGP9OV8OHnk3wEdNVyh1hUP5rUBuMex9z5YMn71u2 5kM739+w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mICNW-00HVyH-2i; Mon, 23 Aug 2021 16:00:50 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mICNI-00HVwa-Sn for linux-arm-kernel@lists.infradead.org; Mon, 23 Aug 2021 16:00:38 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8720911D4; Mon, 23 Aug 2021 09:00:18 -0700 (PDT) Received: from [10.57.42.141] (unknown [10.57.42.141]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 63FDD3F5A1; Mon, 23 Aug 2021 09:00:15 -0700 (PDT) Subject: Re: [PATCH v1 2/3] perf auxtrace: Add compat_auxtrace_mmap__{read_head|write_tail} To: Leo Yan 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 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> <20210823121348.GE100516@leoy-ThinkPad-X240s> From: James Clark Message-ID: <1c0101fd-2ca6-4741-5d72-82d3e00bfeb6@arm.com> Date: Mon, 23 Aug 2021 17:00:14 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210823121348.GE100516@leoy-ThinkPad-X240s> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210823_090037_056753_A57397D8 X-CRM114-Status: GOOD ( 27.41 ) 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 23/08/2021 13:13, Leo Yan wrote: > 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. I see what you mean now, I think keeping it in one section is fine, I would just replace "When update the AUX tail and detects" with "When compat_auxtrace_mmap__write_tail() detects". If the function name is there then it's clear that it's not the return value of compat_auxtrace_mmap__read_head() Thanks James > > Thanks, > Leo > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel