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.4 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 050AEC35257 for ; Fri, 2 Oct 2020 21:28:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6894F207EA for ; Fri, 2 Oct 2020 21:28:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="T9S8Ib37" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6894F207EA 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 98ECE6B0072; Fri, 2 Oct 2020 17:28:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 917EB6B0073; Fri, 2 Oct 2020 17:28:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 790E46B0074; Fri, 2 Oct 2020 17:28:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0241.hostedemail.com [216.40.44.241]) by kanga.kvack.org (Postfix) with ESMTP id 40EBA6B0072 for ; Fri, 2 Oct 2020 17:28:26 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id D65753635 for ; Fri, 2 Oct 2020 21:28:25 +0000 (UTC) X-FDA: 77328274170.20.flag47_460f269271a7 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin20.hostedemail.com (Postfix) with ESMTP id B2F05180C07A3 for ; Fri, 2 Oct 2020 21:28:25 +0000 (UTC) X-HE-Tag: flag47_460f269271a7 X-Filterd-Recvd-Size: 5113 Received: from mail-oo1-f65.google.com (mail-oo1-f65.google.com [209.85.161.65]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Fri, 2 Oct 2020 21:28:25 +0000 (UTC) Received: by mail-oo1-f65.google.com with SMTP id w25so716603oos.10 for ; Fri, 02 Oct 2020 14:28:25 -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=zH8zzrg+xXVXd7NQ8OqgeM7KZ5LB+ZSk1cWcX09tTBI=; b=T9S8Ib37E0nEAzt58/3mFKBcYQZBL+AUZWg1RHKEI8YcEgkzl+zhg+iUyJcShofLym adUy3VXYaVJw4qH0ARA2opXokbhprcecl+xiECKEHSPNPKANK9N041AL1hOWHcZxTISz 75/8QopBKHILebHvJPZCrLtxRg5XQ9sss/ad/Fj7yHOuH8HgviF0halDHMmt+OLPCc46 a32zRvTWfMF/tIVNl2CVHZM3rjchAMQNqj76PE4HOP6RTztczmN4lU4pNfoP12ymVF1D +qutItDnQ2A65FnuPYHsSWxi2ag2I5uWo5diCMXDjG37okMaISf9tYs8byUgPIDGLW7J xG8g== 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=zH8zzrg+xXVXd7NQ8OqgeM7KZ5LB+ZSk1cWcX09tTBI=; b=NQeYlJUVOSUZVBFzBmWWoKoAn/TtUJA0ZKR3mFTA7whMEswoZGS64+lpAPeiz2abJf wqlOANolfHKLMgt1Rn8SKJyy8XP9VrI+4FeVebzCzU7WcqLtZgOEeHP+cICXifn+Z3PU Dwd3cydvD1J0S9ieALqRUFhJkLtNQXq4YibuZdW8Y/BBc8BASTnUVva1j9xt5FwVmHbN +DUvvqaxvke5Vnuf0JwrUE360A4wb2wAKYYKuEIzjNlNXnQ8RVYTBb26Z28XeieWqvnr kYy5rkO9IGYS0YnWO9zKder6PiIWerWo1m1VkN/bqx6JXsmstoCXB31i9YUn9ms3KhzD xROw== X-Gm-Message-State: AOAM532be/CuLgqXWSkk8URGNW0F2cbRYjg4PmLXz0zG4qcqPI6QEh60 zCiwMVyMN7zF4QGSoJJypBmcdvtsGha/lcK7evU5kg== X-Google-Smtp-Source: ABdhPJxOUoZnl87DrHfbRoTmo20SXV41YO+PeAn+DWWBv9LR0ddLe4qAXxw5Nx6yNfCgJCH4HtSP2kXaFFs8y0NqANA= X-Received: by 2002:a4a:4fd0:: with SMTP id c199mr3387390oob.54.1601674104417; Fri, 02 Oct 2020 14:28:24 -0700 (PDT) MIME-Version: 1.0 References: <20200929133814.2834621-1-elver@google.com> <20200929133814.2834621-2-elver@google.com> <20201002171959.GA986344@elver.google.com> In-Reply-To: From: Marco Elver Date: Fri, 2 Oct 2020 23:28:12 +0200 Message-ID: Subject: Re: [PATCH v4 01/11] mm: add Kernel Electric-Fence infrastructure To: Jann Horn Cc: Andrew Morton , Alexander Potapenko , "H . Peter Anvin" , "Paul E . McKenney" , Andrey Konovalov , 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 , Jonathan Cameron , Jonathan Corbet , Joonsoo Kim , Kees Cook , Mark Rutland , Pekka Enberg , Peter Zijlstra , SeongJae Park , Thomas Gleixner , Vlastimil Babka , Will Deacon , "the arch/x86 maintainers" , "open list:DOCUMENTATION" , kernel list , kasan-dev , Linux ARM , Linux-MM , SeongJae Park 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 Fri, 2 Oct 2020 at 21:32, Jann Horn wrote: > > That's another check; we don't want to make this more expensive. > > Ah, right, I missed that this is the one piece of KFENCE that is > actually really hot code until Dmitry pointed that out. > > But actually, can't you reduce how hot this is for SLUB by moving > is_kfence_address() down into the freeing slowpath? At the moment you > use it in slab_free_freelist_hook(), which is in the super-hot > fastpath, but you should be able to at least move it down into > __slab_free()... > > Actually, you already have hooked into __slab_free(), so can't you > just get rid of the check in the slab_free_freelist_hook()? I missed this bit: the loop that follows wants the free pointer, so I currently see how this might work. :-/ We'll look at your other email re optimizing is_kfence_address() next week; and thank you for the detailed comments thus far! Thanks, -- Marco