Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2619615pxb; Sun, 17 Oct 2021 20:42:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0tkzgB/IfkDXZIX7aPtmGwE4Jk+HbCPFqUOXvO7+cIMuXulxqyieH+/L2MnDLzRWh7dKd X-Received: by 2002:a05:6a00:1901:b0:44b:e041:f07f with SMTP id y1-20020a056a00190100b0044be041f07fmr26320007pfi.52.1634528564769; Sun, 17 Oct 2021 20:42:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634528564; cv=none; d=google.com; s=arc-20160816; b=ROjo6zuUNTiLYKk1QjFmZzasdLkjYKP2U3A0UpZQ2OPlUmK/PSEITCC5Wf5zRTMRKX pULyCDx1uISEAP7PLFj0X4n2z1DmboQ+mhpf7drS4xX2FPqSsLed23VUi7spD4NwRXzw 0Njus+f3tV0SKexC5xKqHmdJrfHolLTMoEKSeruVmxUfracb9F2jrjzv55FL3OXfxFg8 MXKymUiO3tEjknVFW5GH9REHhZjNHqi+kVImeA2DYHBuOzq5D4h7yVz+Jw2f2UmSBs3l +LkImayuzvxuZ9S4OONFdj/XqvAt5+DkBYGoMvlvj13Rcex4Mec14U3yWA4JL9f+c187 AsfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=ohO5ogKSAkRU2HlGVfuByKrc4u8vbxINrbBIB21Ms4k=; b=TkmznRTRjkuclaegOQXRPDQ6TBfyoT0rSkqFPs8QxRLbyOo5jSYRc6EsllxTHZjS+b GdeX8p1Rj+dKrHDAFpoac1ZWe3rtnDnt1b6y3FZ2HL3nFC0yc2qJBcLr7pfZ1+8VYbEP D0ASPQeDpl546DqeI638eecC1BMugzCMQuqWmr5/n1NPkdstKcu8aVyIfSdS0+q6Gx3Y ygKWBYnvMK6oleH2pLgHif8uHUUOFYyFvPZMRHTQMunr2a8/LgvSbNTFSonLYw6LjCW8 Hzbv0pt4yZij2aHiqWhMr6ZCZ9tgGWHuI44DxhwZ/h0CAnhtVpor7jTh3f+CRiEApHaN 7C/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=fij2Te9e; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a6si20703982pfv.21.2021.10.17.20.42.30; Sun, 17 Oct 2021 20:42:44 -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=@gmail.com header.s=20210112 header.b=fij2Te9e; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244951AbhJQEb2 (ORCPT + 98 others); Sun, 17 Oct 2021 00:31:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244942AbhJQEbX (ORCPT ); Sun, 17 Oct 2021 00:31:23 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE0D8C06176D for ; Sat, 16 Oct 2021 21:28:57 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id q19so12003719pfl.4 for ; Sat, 16 Oct 2021 21:28:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=ohO5ogKSAkRU2HlGVfuByKrc4u8vbxINrbBIB21Ms4k=; b=fij2Te9eph7sxFwrTV3Yyszsi/5a01jQRHiSPC6JhEF9aaMga3qb008F1hR543abrn PuBNmzeFL3hJk12hRBJuRBpqS3WcFLzsOt3V6yQqyuIDu3fYbqlUXzkEGgHb9X9a2Jxg +gFL0vptv39nLYM/jmoRTTh+RB+0dAex9JtauPpN6nIzJYhxwLCwqaxiTRiaNSXrmksu Dct+sZC2dh+coTIUvwVST3bkK+JyvYtOui+Vowa1gjnBafAHFvMQG7Gq/pLpaGOXpV94 B5ohOSxWZRxHDKckLsOPjcUcAO0uO5bkltGBYnvbd8/iD8F6/LHWPHVhjDv9afLN00Ub jOWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=ohO5ogKSAkRU2HlGVfuByKrc4u8vbxINrbBIB21Ms4k=; b=AgjXaDBQ7ILWKbKGjZFrYdMkqpjKTaPQu5KspMyutjKNyAO+o7TVuhgslsi58BlA2L PpsYpuqoO2wnMHExLhhigFc871zaXWo4L2/auZgv6hf4YNtO6Lpy4gZmc7kZV7/fd4Gm 68RGOL8nZ7iIC3G2Ls/SzBjkbtqkKHqiperQus8oXAS086RBj2++4aYH9QdSCQdFmuTI a2ES0dANJ8+Rf0G0fmQlT+rCzo3AfiEKUQRSVLzA9jvUxr+5SBrfLpsvktbT7lsgR1wP 7Kg14YPSWG7SDC5mjDPwTjW29kPKD7Q7EoACZvlLOUoDA2Rg6aIVIJoxGuPW8Y8TA2E+ ZLFQ== X-Gm-Message-State: AOAM531PXVCMYRAs7x23RDae7xksLYpaZBhjo1NpQTx/8MzlU79Quu9U IoW6V8WRAnV4fcRbh6HDMyM= X-Received: by 2002:a63:3f4f:: with SMTP id m76mr9745128pga.315.1634444937058; Sat, 16 Oct 2021 21:28:57 -0700 (PDT) Received: from kvm.asia-northeast3-a.c.our-ratio-313919.internal (24.151.64.34.bc.googleusercontent.com. [34.64.151.24]) by smtp.gmail.com with ESMTPSA id p25sm2063406pfh.86.2021.10.16.21.28.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Oct 2021 21:28:56 -0700 (PDT) Date: Sun, 17 Oct 2021 04:28:52 +0000 From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Hyeonggon Yoo <42.hyeyoo@gmail.com> Subject: [RFC] More deterministic SLOB for real time embedded systems Message-ID: <20211017042852.GA3050@kvm.asia-northeast3-a.c.our-ratio-313919.internal> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I've been reading SLUB/SLOB code for a while. SLUB recently became real time compatible by reducing its locking area. for now, SLUB is the only slab allocator for PREEMPT_RT because it works better than SLAB on RT and SLOB uses non-deterministic method, sequential fit. But memory usage of SLUB is too high for systems with low memory. So In my local repository I made SLOB to use segregated free list method, which is more more deterministic, to provide bounded latency. This can be done by managing list of partial pages globally for every power of two sizes (8, 16, 32, ..., PAGE_SIZE) per NUMA nodes. minimal allocation size is size of pointers to keep pointer of next free object like SLUB. By making size of objects in same page to have same size, there's no need to iterate free blocks in a page. (Also iterating pages isn't needed) Some cleanups and more tests (especially with NUMA/RT configs) needed, but want to hear your opinion about the idea. Did not test on RT yet. Below is result of benchmarks and memory usage. (on !RT) with 13% increase in memory usage, it's nine times faster and bounded fragmentation, and importantly provides predictable execution time. current SLOB: memory usage: Slab: 7936 kB hackbench: Time: 263.900 Performance counter stats for 'hackbench -g 4 -l 10000': 527649.37 msec cpu-clock # 1.999 CPUs utilized 12451963 context-switches # 23.599 K/sec 251231 cpu-migrations # 476.132 /sec 4112 page-faults # 7.793 /sec 342196899596 cycles # 0.649 GHz 228439896295 instructions # 0.67 insn per cycle 3228211614 branch-misses 65667138978 cache-references # 124.452 M/sec 7406902357 cache-misses # 11.279 % of all cache refs 263.956975106 seconds time elapsed 5.213166000 seconds user 521.716737000 seconds sys SLOB with segregated free list: memory usage: Slab: 8976 kB hackbench: Time: 28.896 Performance counter stats for 'hackbench -g 4 -l 10000': 57669.66 msec cpu-clock # 1.995 CPUs utilized 902343 context-switches # 15.647 K/sec 10569 cpu-migrations # 183.268 /sec 4116 page-faults # 71.372 /sec 72101524728 cycles # 1.250 GHz 68780577270 instructions # 0.95 insn per cycle 230133481 branch-misses 23610741192 cache-references # 409.414 M/sec 896060729 cache-misses # 3.795 % of all cache refs 28.909188264 seconds time elapsed 1.521686000 seconds user 56.105718000 seconds sys