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 D1404C46466 for ; Fri, 2 Oct 2020 21:28:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8E0F3208C7 for ; Fri, 2 Oct 2020 21:28:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="T9S8Ib37" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725765AbgJBV2Z (ORCPT ); Fri, 2 Oct 2020 17:28:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725355AbgJBV2Z (ORCPT ); Fri, 2 Oct 2020 17:28:25 -0400 Received: from mail-oo1-xc43.google.com (mail-oo1-xc43.google.com [IPv6:2607:f8b0:4864:20::c43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 592FFC0613D0 for ; Fri, 2 Oct 2020 14:28:25 -0700 (PDT) Received: by mail-oo1-xc43.google.com with SMTP id y25so720064oog.4 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=Oqr7p45TqUsZPWzObDSSa8LiPqPAV5cIkazz/THJHzrfcJYwYjdpHeSODwhlwk5hVb 4U261Xn6r6eLUs8ZEmbG6U4JVxjluLBMEgva3vCKy18U9tJ0zfLkHJRROeq757BKy32J oOSZduClU7d1zFgRiTBXjrQAN/Rs5kV25EgbAHb/9KaIL8oiOyYvHtWhyKAxtoxYenad SoTAjbJ4t0j2Pqzneoo/oBwHcD73Mgfx5Mi5Mbed5Xxd2lyznb3xZ/8+E4M8ynHO6I0m fP2vvZE3Diz7ek9hGxf5kH/oe0rlVEGeXfPpVa9ttzriTeyxwUcSfJ0i3o+hUr/Bxxfv JEJA== X-Gm-Message-State: AOAM533Kpzn4pNQHUiO7+jLMEOsPBx8F5x+4S+/MrEr9sUA5CHoOOpgK BrgPZaDxYElIqzFXiZaccmPXWdT4RARpK8dnYATiiw== 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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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