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=-11.9 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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 68F7EC4727D for ; Tue, 29 Sep 2020 13:48:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BEFE521531 for ; Tue, 29 Sep 2020 13:48:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="bSfQ00UY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BEFE521531 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BE0B06B0062; Tue, 29 Sep 2020 09:48:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BB6008E0001; Tue, 29 Sep 2020 09:48:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ACD066B006E; Tue, 29 Sep 2020 09:48:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0168.hostedemail.com [216.40.44.168]) by kanga.kvack.org (Postfix) with ESMTP id 973D06B0062 for ; Tue, 29 Sep 2020 09:48:40 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 53239180AD801 for ; Tue, 29 Sep 2020 13:48:40 +0000 (UTC) X-FDA: 77316229200.21.coast06_52089b52718a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id 2EB9118041611 for ; Tue, 29 Sep 2020 13:48:40 +0000 (UTC) X-HE-Tag: coast06_52089b52718a X-Filterd-Recvd-Size: 4778 Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) by imf33.hostedemail.com (Postfix) with ESMTP for ; Tue, 29 Sep 2020 13:48:39 +0000 (UTC) Received: by mail-pj1-f68.google.com with SMTP id t7so2700333pjd.3 for ; Tue, 29 Sep 2020 06:48:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=IPm4tw86pN2WUua3zyIf+UMu5higdStDKbiJez1ULJI=; b=bSfQ00UYm4VoJlquAI7V6jVEQo4rLlwg3aERyFQwm5d2bcD2RuSliJPcyonBtdq/ZN VvtPxIglw3bP70TwMysOCQigvfrpJG5cVvoGzuxUOz7ebd0+R2+WOVxDLfja2EdFIw86 oHju9/tu+hGRSe9XSlz1mv37TYzGHHLo4MOIeW6BT9yq9OAOppmMVmVdbr59zPAquJ0Q zIkQ3Jje0wj7eyMksGfm8fCOIsbSb8gjJJqa/fCHSQ1EYhDH+S9HIJvVGKkVpicjB299 UPjQVRx2K+46bs+6lG7chdR0y5VBQTLqBCRUr0knfqDC/5w+scyhixQ/3URhOBW5mDq2 naWQ== 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=IPm4tw86pN2WUua3zyIf+UMu5higdStDKbiJez1ULJI=; b=ps32BC0bEP/LgV3R1ZJSH1XJ1Yqn3RzLOgZqZQvzgQedGyd5eiEO2fyqkTLCXNYyNW 7UniYPlvNfRwMPBvaE5dh7QVHxt/I/KuftTUT8WHl6XiypQJNR9ILva/bYqKPRfdTCQX QXksDlpM3IcuRJhoPZz5awlqmiT1QLWs7P1SFMYLC8kq4VWRMjVE+69Ha2tlOTy3QM8A AyZOF3ZZP5w3S1mpvFHCWJ4fOGR9dN4Pr9krX0F5DVwkDm5dxGfhnlcP2xKHq+Tmoamg 4xnS9dBf+xOjwcSbz/PSvVFdEwfF96dIgWiTRpz+kj0c1WoCe2T3cgBN9zUwe03tlzTi DHVw== X-Gm-Message-State: AOAM531hL6DDHxibo9mmb7xT9tu6ryzx7E6Q7SgcPgGTOr+ZTtwc/fuP MEZSueWUU2vNtqelj4XesX3rVgIbT1sKr5Ffps73wg== X-Google-Smtp-Source: ABdhPJw47F0+7jUDxETZXpy6HGkN76Pw3ijxd4TL/rithtPlxyOge6EdgdmYyxt2sw1OTCcxptDiCw/No4O/AUpJpcs= X-Received: by 2002:a17:90a:81:: with SMTP id a1mr3910753pja.136.1601387318512; Tue, 29 Sep 2020 06:48:38 -0700 (PDT) MIME-Version: 1.0 References: <20200921132611.1700350-1-elver@google.com> <20200921132611.1700350-2-elver@google.com> <20200929131135.GA2822082@elver.google.com> In-Reply-To: <20200929131135.GA2822082@elver.google.com> From: Andrey Konovalov Date: Tue, 29 Sep 2020 15:48:27 +0200 Message-ID: Subject: Re: [PATCH v3 01/10] mm: add Kernel Electric-Fence infrastructure To: Marco Elver Cc: Andrew Morton , Alexander Potapenko , "H. Peter Anvin" , "Paul E . McKenney" , Andrey Ryabinin , Andy Lutomirski , Borislav Petkov , Catalin Marinas , Christoph Lameter , Dave Hansen , David Rientjes , Dmitry Vyukov , Eric Dumazet , Greg Kroah-Hartman , Hillf Danton , Ingo Molnar , Jann Horn , Jonathan.Cameron@huawei.com, Jonathan Corbet , Joonsoo Kim , Kees Cook , Mark Rutland , Pekka Enberg , Peter Zijlstra , sjpark@amazon.com, Thomas Gleixner , Vlastimil Babka , Will Deacon , "the arch/x86 maintainers" , "open list:DOCUMENTATION" , LKML , kasan-dev , Linux ARM , Linux Memory Management List Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Sep 29, 2020 at 3:11 PM Marco Elver wrote: > > On Tue, Sep 29, 2020 at 02:42PM +0200, Andrey Konovalov wrote: > [...] > > > + */ > > > + index = (addr - (unsigned long)__kfence_pool) / (PAGE_SIZE * 2) - 1; > > > > Why do we subtract 1 here? We do have the metadata entry reserved for something? > > Above the declaration of __kfence_pool it says: > > * We allocate an even number of pages, as it simplifies calculations to map > * address to metadata indices; effectively, the very first page serves as an > * extended guard page, but otherwise has no special purpose. > > Hopefully that clarifies the `- 1` here. So there are two guard pages at the beginning and only then a page that holds an object?