Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp6184602rdb; Mon, 18 Sep 2023 06:41:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE8EhQEnwGTvG/4sgVDbygAY5OBUR9WZt26uTt9n3DXrtqrJbxz0NtdGR3j/Y/m6cwfph5N X-Received: by 2002:a05:6a20:748e:b0:156:e1ce:d4a4 with SMTP id p14-20020a056a20748e00b00156e1ced4a4mr7989631pzd.54.1695044516314; Mon, 18 Sep 2023 06:41:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695044516; cv=none; d=google.com; s=arc-20160816; b=Y1ziOvjDzvr1NF9j+ARy3hGLer7AlTKgMG7EKH4kHvgVgKlVkiTluiBbFTVkIzgtIA rEuZeeTYQZ4R8qYwwmwVbp694QYvpku+iCJKEwtO3eAg+nKSkHrhnBD3hLTvz/Fw0D5j A3GklXg+Ha0ncH9xFfYzYWsy8ba6gZ8u6EevYrKFBFcFQ4fiYr2y8iUM1IXW9gnrBH/A JHJS0DLEwFH897LrM9VLBaJn/Y4DC6S/sKDjyGYGpfpzWWuio2lSerTvfl6zTbypHqW1 JHu1wVECZoQEL4SNEgKCSArs1QpTw+2qLYxychbMFFEHEyhK1ldAkz5Jh9LTV3LoIkop NIRw== 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=ziZvMGLK6JgmUUboWqZiWtfE7gVK2DDQAWWdwk2gDB8=; fh=6V6hqvDhYF1XIbe89ln8FWb6R61/mX5gVBb+qsOwgdg=; b=CBXImo33RfDwzvwBs9yeiIxYEWHjWjJTvgLqG3/vVPZedvS9Hq+GrBkeZ1x9EGl0Je Jg2iQbi99ABCNM/KR+nIAXR1jvqOx7ql5/Cap7DfJlL4Al5P/+xEjlMaW7OjdrXio+DP 9eA+iewHAlawFbtMMFE2Rz207palb9jNfPeGNIdrkwoVBRU6aLeC+WM1BxgzTDaqLU/8 Xq/YBmu7CxJqAON1fO3pqCSLnSzALpZ+Lk087Db6gyNzdyvYYEmF8C68kqVN/mkMcn+X XTanXIXW0NZkqs+0kLX5qFh+HRPHzUxANifDBdlQHOCL9ZGUBjyBG55qUoGBQE3bq1LW g4ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=p61uxtX0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id v69-20020a638948000000b005649f560ebesi7946950pgd.525.2023.09.18.06.41.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 06:41:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=p61uxtX0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id E4B7F809D478; Mon, 18 Sep 2023 05:09:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241915AbjIRMJN (ORCPT + 99 others); Mon, 18 Sep 2023 08:09:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241984AbjIRMJA (ORCPT ); Mon, 18 Sep 2023 08:09:00 -0400 Received: from mail-qv1-xf2c.google.com (mail-qv1-xf2c.google.com [IPv6:2607:f8b0:4864:20::f2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C125A0 for ; Mon, 18 Sep 2023 05:08:55 -0700 (PDT) Received: by mail-qv1-xf2c.google.com with SMTP id 6a1803df08f44-6515d44b562so25704656d6.3 for ; Mon, 18 Sep 2023 05:08:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695038934; x=1695643734; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=ziZvMGLK6JgmUUboWqZiWtfE7gVK2DDQAWWdwk2gDB8=; b=p61uxtX0s6QXhc4OmvJvspTqCcs2jz3xrCH+J4noLOoD1mjKzM0525uRVmVJyeilS4 hITA3Njo9vEato1lC05/6upCAPiyHpNEzm6+vkejZDLfpWZ6Uq06/XKDJO3TGRZEA4x3 Li+i7BI+ooan++z/FQ3wS/cQEFl7WbpG2KWcv4tMOcFu2VlGfcWsC+8Ag5Ragp5O6xcn X8dJ/T4Fn6/bakka1UpaJFJIn0TTf9o/MOx1bsZOPfs/9CSHOSD4wjPBOBqMRyAE2ywV QJfivMQjREm23VomDYxMjvNdlh3+lTK+F8rX2XcD0/bMlTtHu2D0t6vAsuN0Lwt53HK5 ZBUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695038934; x=1695643734; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ziZvMGLK6JgmUUboWqZiWtfE7gVK2DDQAWWdwk2gDB8=; b=HrIom0vTAH5dXtNON4G2k1RSPymqSsvhzsn6lmyyPwJ1d78TmkbrRz/uVcmfc4hHPQ q7r5bQop0v7bnJRYSLwbJPdkfwOufZucHNLCkXo1x9p42PrwslxcQAvNKnIKFvP9mKPc GBEJgTaYjf5oQFFSMyYnacvMyI2pqgo5bxmrDdrLu3LKGFSibSuFwycCBoYRchgy7LEM UKjxdQDE2mCH+h//+2BlRRxX9ood/Nxonxqp2Hna6HrrgiFrkOav4KzBctSFFdGpvJfS TaXEWHUnt3wsLKA4aDwnvSNNY21Dfed6DeDGBDxCdbmqq1+G8ygY75BqKKTWK0AM8WP5 QIoA== X-Gm-Message-State: AOJu0YxuePPL1PNGRDSugB/l0+gVo8+GrN+EL8opSZuoPdoqTrZPyOil cZy812ml2rIEorjb0adoafD8fZIzVBqGAEc/wI16cw== X-Received: by 2002:a0c:cc82:0:b0:656:5337:e7bd with SMTP id f2-20020a0ccc82000000b006565337e7bdmr4263366qvl.3.1695038934426; Mon, 18 Sep 2023 05:08:54 -0700 (PDT) MIME-Version: 1.0 References: <20230915105933.495735-1-matteorizzo@google.com> <7a4f5128-28fd-3c5f-34c2-1c34f4448174@intel.com> <1d7573c0-ebbc-6ed2-f152-1045eb0542f9@os.amperecomputing.com> In-Reply-To: <1d7573c0-ebbc-6ed2-f152-1045eb0542f9@os.amperecomputing.com> From: Matteo Rizzo Date: Mon, 18 Sep 2023 14:08:43 +0200 Message-ID: Subject: Re: [RFC PATCH 00/14] Prevent cross-cache attacks in the SLUB allocator To: "Lameter, Christopher" Cc: Dave Hansen , penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, vbabka@suse.cz, roman.gushchin@linux.dev, 42.hyeyoo@gmail.com, keescook@chromium.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-hardening@vger.kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, corbet@lwn.net, luto@kernel.org, peterz@infradead.org, jannh@google.com, evn@google.com, poprdi@google.com, jordyzomer@google.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.4 required=5.0 tests=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=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 18 Sep 2023 05:09:45 -0700 (PDT) On Fri, 15 Sept 2023 at 18:30, Lameter, Christopher wrote: > > On Fri, 15 Sep 2023, Dave Hansen wrote: > > > What's the cost? > > The only thing that I see is 1-2% on kernel compilations (and "more on > machines with lots of cores")? I used kernel compilation time (wall clock time) as a benchmark while preparing the series. Lower is better. Intel Skylake, 112 cores: LABEL | COUNT | MIN | MAX | MEAN | MEDIAN | STDDEV ---------------+-------+---------+---------+---------+---------+-------- SLAB_VIRTUAL=n | 150 | 49.700s | 51.320s | 50.449s | 50.430s | 0.29959 SLAB_VIRTUAL=y | 150 | 50.020s | 51.660s | 50.880s | 50.880s | 0.30495 | | +0.64% | +0.66% | +0.85% | +0.89% | +1.79% AMD Milan, 256 cores: LABEL | COUNT | MIN | MAX | MEAN | MEDIAN | STDDEV ---------------+-------+---------+---------+---------+---------+-------- SLAB_VIRTUAL=n | 150 | 25.480s | 26.550s | 26.065s | 26.055s | 0.23495 SLAB_VIRTUAL=y | 150 | 25.820s | 27.080s | 26.531s | 26.540s | 0.25974 | | +1.33% | +2.00% | +1.79% | +1.86% | +10.55% Are there any specific benchmarks that you would be interested in seeing or that are usually used for SLUB? > Problems: > > - Overhead due to more TLB lookups > > - Larger amounts of TLBs are used for the OS. Currently we are trying to > use the maximum mappable TLBs to reduce their numbers. This presumably > means using 4K TLBs for all slab access. Yes, we are using 4K pages for the slab mappings which is going to increase TLB pressure. I also tried writing a version of the patch that uses 2M pages which had slightly better performance, but that had its own problems. For example most slabs are much smaller than 2M, so we would need to create and map multiple slabs at once and we wouldn't be able to release the physical memory until all slabs in the 2M page are unused which increases fragmentation. > - Memory may not be physically contiguous which may be required by some > drivers doing DMA. In the current implementation each slab is backed by physically contiguous memory, but different slabs that are adjacent in virtual memory might not be physically contiguous. Treating objects allocated from two different slabs as one contiguous chunk of memory is probably wrong anyway, right? -- Matteo