Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1978983pxb; Mon, 23 Aug 2021 09:05:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUCgCoPbspPm+V8wLny8lR87MGE67glvmdbI52mGbTk2lE/72YLkc1ppIJkFdzobO5eCIw X-Received: by 2002:a17:906:2bcf:: with SMTP id n15mr36881110ejg.414.1629734731403; Mon, 23 Aug 2021 09:05:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629734731; cv=none; d=google.com; s=arc-20160816; b=fwWi7WFt5E+yKP/jlQw8CJRASqSWZ12SQXpdsq2xDEklQsmMqYZkhadt7+nnIABNnf FvAvEKEiF2/34xC8gTDHerD300ZhNUm+a5KQvAU/WSXZWjGZXKKMaGV7NqdgZcnUfVkE Q1fSvdaR8Yg1e+ShYaJ2tB9028YlpCxp6apMvSH7C1CFS6unXV6wme1gsjfO277ovx6F d19IdQpaacFk7U03NbWjfUoC7nlycD1JeSCKJbbBtRTOxxka3drZJSA8axjBBQYS11S1 HHwQdUvO1Xik4+Vni1CfYxdSVZb4S0uhm1S2eXbWW45fS84ecbmhis107THULVDRYrdC PhNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=BM21oQEco//9nTIyV4EoA/auYqsVCNfXInYSEeQCB+U=; b=YHp5yFP4t+RRld9EbtLLpJCKbj9WLFR1jtMIroimaG37btQYB4e37pYpuRmNLjb49d fMhQ5uJHdZgtC4OwErpvni5VWhse4dVVpmmi3xIfBD6Eo+6O+Z5J/leIrz9Uc3Le0Yro CluE8oXyiXXwVN1uk6Lpp9EBVh0U4PoPzPVWo0jNdZYbC3A7c8RlRv2oQScfPcVsPive R8X1ARvJrZzhNNMPFrCkLDyCiKqDT4ThgmxvpX2TEkkRg82TSnEYpOEdoKVuUSE3GTTN laRDoCSQkgTavB+W6IRiFixgWnTEtWUdG1uiXroCc1no//rDhoiv0GFuGMOPVs6HGvb3 b7QQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id kx11si14706256ejc.554.2021.08.23.09.05.07; Mon, 23 Aug 2021 09:05:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231808AbhHWQBC (ORCPT + 99 others); Mon, 23 Aug 2021 12:01:02 -0400 Received: from foss.arm.com ([217.140.110.172]:54852 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231272AbhHWQBB (ORCPT ); Mon, 23 Aug 2021 12:01:01 -0400 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-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 >