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.6 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,URIBL_BLOCKED,USER_AGENT_SANE_1 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 5809FC433E0 for ; Mon, 18 Jan 2021 10:58:12 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 D2B0222242 for ; Mon, 18 Jan 2021 10:58:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D2B0222242 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=xh5P/5Jq5NjNAlzLspP6PgEenz14rjMjICruAm+3+2M=; b=CcNjDqslbcwBTwYf006h+48Ku r8xvq2ATlQiLtQ66lj1sBYB5xOhKvBPgmU24HRhArpY3xVgRor5D7rgHHKJyPTsH43Tvr4l3+kVYR 6rqqimWMYswhskvqQOjWT/IFhDJ8lxrI8T1EkTetc2AFDCDi8Qeqs8Ys5VyT6rVfEAY+SIWqOSD5y B6khE9ddDWGE089I0l2ywKQEbqiiZR+E7V+789r5smZegpn6nLSHEZs0R9gQ5Bb357k7w6upQtTdX lBAK7m34i3gR5RMMjKbE9JbcOLE6qiI8B9IlefynLY71RAC5sR/sLDoBqhgvh9Eh7l+VW5alXIrZn 7lCNsj5Sw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l1SDX-0000qL-50; Mon, 18 Jan 2021 10:57:03 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l1SDP-0000mv-VU for linux-arm-kernel@lists.infradead.org; Mon, 18 Jan 2021 10:56:56 +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 907681FB; Mon, 18 Jan 2021 02:56:53 -0800 (PST) Received: from [10.37.8.29] (unknown [10.37.8.29]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EF5F33F68F; Mon, 18 Jan 2021 02:56:50 -0800 (PST) Subject: Re: [PATCH v3 4/4] arm64: mte: Optimize mte_assign_mem_tag_range() To: Mark Rutland References: <20210115120043.50023-1-vincenzo.frascino@arm.com> <20210115120043.50023-5-vincenzo.frascino@arm.com> <20210115154520.GD44111@C02TD0UTHF1T.local> <4b1a5cdf-e1bf-3a7e-593f-0089cedbbc03@arm.com> <0c1b9a6b-0326-a24f-6418-23a0723adecf@arm.com> <20210118104116.GB29688@C02TD0UTHF1T.local> From: Vincenzo Frascino Message-ID: Date: Mon, 18 Jan 2021 11:00:38 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20210118104116.GB29688@C02TD0UTHF1T.local> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210118_055656_092818_D8D451CA X-CRM114-Status: GOOD ( 22.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Branislav Rankov , Marco Elver , Catalin Marinas , Evgenii Stepanov , linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, Alexander Potapenko , linux-arm-kernel@lists.infradead.org, Andrey Konovalov , Andrey Ryabinin , Will Deacon , Dmitry Vyukov 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 1/18/21 10:41 AM, Mark Rutland wrote: > On Sun, Jan 17, 2021 at 12:27:08PM +0000, Vincenzo Frascino wrote: >> Hi Mark, >> >> On 1/16/21 2:22 PM, Vincenzo Frascino wrote: >>>> Is there any chance that this can be used for the last bytes of the >>>> virtual address space? This might need to change to `_addr == _end` if >>>> that is possible, otherwise it'll terminate early in that case. >>>> >>> Theoretically it is a possibility. I will change the condition and add a note >>> for that. >>> >> >> I was thinking to the end of the virtual address space scenario and I forgot >> that if I use a condition like `_addr == _end` the tagging operation overflows >> to the first granule of the next allocation. This disrupts tagging accesses for >> that memory area hence I think that `_addr < _end` is the way to go. > > I think it implies `_addr != _end` is necessary. Otherwise, if `addr` is > PAGE_SIZE from the end of memory, and `size` is PAGE_SIZE, `_end` will > be 0, so using `_addr < _end` will mean the loop will terminate after a > single MTE tag granule rather than the whole page. > > Generally, for some addr/increment/size combination (where all are > suitably aligned), you need a pattern like: > > | do { > | thing(addr); > | addr += increment; > | } while (addr != end); > > ... or: > > | for (addr = start; addr != end; addr += increment) { > | thing(addr); > | } > > ... to correctly handle working at the very end of the VA space. > > We do similar for page tables, e.g. when we use pmd_addr_end(). > Good point! I agree it wraps around otherwise. I will change it accordingly. Thanks! > Thanks, > Mark. > -- Regards, Vincenzo _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel