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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9368BC433EF for ; Sun, 17 Oct 2021 04:29:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 15A1361108 for ; Sun, 17 Oct 2021 04:28:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 15A1361108 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 4B03A900002; Sun, 17 Oct 2021 00:28:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 45FDF6B0072; Sun, 17 Oct 2021 00:28:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 34E55900002; Sun, 17 Oct 2021 00:28:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0135.hostedemail.com [216.40.44.135]) by kanga.kvack.org (Postfix) with ESMTP id 260A06B006C for ; Sun, 17 Oct 2021 00:28:59 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id BDFBE180257C7 for ; Sun, 17 Oct 2021 04:28:58 +0000 (UTC) X-FDA: 78704649156.10.8527BFC Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by imf18.hostedemail.com (Postfix) with ESMTP id 7A3DF4002087 for ; Sun, 17 Oct 2021 04:28:56 +0000 (UTC) Received: by mail-pf1-f178.google.com with SMTP id m26so12010702pff.3 for ; Sat, 16 Oct 2021 21:28:58 -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=ZYeDPD0dVxKNUqa0jCV5db1jpWvdV9CYub+sX/kDM2B/ATPlFJ9ksaUmDiv9CjzLgZ D9QLrlfjCTKqeLPAPONwYZ0xx5dJAcwDllLMjSTuGisgB59b9u0B9xJ25U5n0YVtCviP hv61T8nzvAnUNJvRVCY4B2lIk3EBtL+z7FDoxDL9w59xxC1yEU0BMhcwUV1tHOe4gbtu 7aJiVEwcPX6nV+4K1QrHmaWputiSJujTte4nJA11f/eD0+ENMVUrvtjujD57FRvoqUpV NGe4uLP2eUccEZ1jt5fu/7K4Cu2Eq3lKtvw3CLZTzkgOGfqiq/65JK6ma34rUhkYsqxt denA== X-Gm-Message-State: AOAM532bRUCGSBDqor4Ghx3ST2RugALMEnbscuyYSfa4mh4cMZ/2dtRn ui+nukqfKeRBZysIrZ8qRcSM+p8qL5k= X-Google-Smtp-Source: ABdhPJxLCMuYDHuwtsT3z4nWa3gYXTVa5DS6waE/Rj1zL3eLYHq3VynHB7by5vvJHWCZ3Jr56AajcQ== 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 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 7A3DF4002087 X-Stat-Signature: o5xr8c3yu6586sr5hqeknaddim1874es Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=fij2Te9e; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf18.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.210.178 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com X-HE-Tag: 1634444936-523344 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: 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