Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1619098pxk; Fri, 2 Oct 2020 14:31:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvCzpCPEpAwyZFfGStRSWyFJfSjfcdkU6JTCRUfEqLgELbHi0YzNRdyH1w2PC01/0YbwvW X-Received: by 2002:a50:9e82:: with SMTP id a2mr4658405edf.117.1601674306903; Fri, 02 Oct 2020 14:31:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601674306; cv=none; d=google.com; s=arc-20160816; b=uTEX+pyd5iRFSXY6zIeVqfbbRvgnpkKOrOuGhLls6lj7GpsetBvCut2VgVIf09jabf XuWsoETaaMSXQxoU/IoIjxzx0mzHTcTseeXND6rgSjRslGt1tMc8N0aKuFmI2orggBnh aMWw9lyXoODx87tbmkYVgfHdknB+bu8r50Xz55JqwRRiB083W7/6RonGSzyd3oaB8Mh9 hQZ1JLBoooxi+xNfNASUPyZC43sxBY33MI3K2SfslWmaimHeJ5quGa/FoMjcwbyaj/7V hrFu2PiLCU5SwKPTogl/LTS71Up9Qapb9VO5/6Iah4J0bsQcOwqLQ9LysM79uXjn2mjw 0NQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=zH8zzrg+xXVXd7NQ8OqgeM7KZ5LB+ZSk1cWcX09tTBI=; b=sdCY726X0tHos/t80QvGUnUHdlkHcWU6jt33eEyXek8m38wscCDJIB81+C9L0wwBRm ttmf6uIxLkeLBPAnPzE1bw7mp7vClTh6/ZzfpodL5SDsmxRfGaZikHYOLBzdfll0Y/V9 EopDef1Gv4NP0A9zs0IPM249vo2Pdo/d24fvWZLfkks84KCMSWjrnZEXNRffK8kCXYJa gbLxEai0nHGRwzIeT2cTru4a9LuL8SFKQljtrXTb20aUK6KoV6yn6Y8JZ26tyJTh4eHJ FVt2Va8F1dJsdPuHMm70pbHSK5dorp07SiV3LpDbGuUazo+KfhdSp34WFSgaiQ/Ue/Xt 6Flg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=T9S8Ib37; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c11si2075388edw.277.2020.10.02.14.31.24; Fri, 02 Oct 2020 14:31:46 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=T9S8Ib37; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725379AbgJBV2Z (ORCPT + 99 others); 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-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