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 4617FC433EF for ; Sun, 24 Oct 2021 10:43:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C44CE60F6F for ; Sun, 24 Oct 2021 10:43:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C44CE60F6F 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 0D7C16B006C; Sun, 24 Oct 2021 06:43:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 087F16B0071; Sun, 24 Oct 2021 06:43:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E9204940007; Sun, 24 Oct 2021 06:43:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0041.hostedemail.com [216.40.44.41]) by kanga.kvack.org (Postfix) with ESMTP id DB1516B006C for ; Sun, 24 Oct 2021 06:43:46 -0400 (EDT) Received: from smtpin37.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 89AD418037C7D for ; Sun, 24 Oct 2021 10:43:46 +0000 (UTC) X-FDA: 78730995252.37.75F64EB Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) by imf27.hostedemail.com (Postfix) with ESMTP id 357CD70000A0 for ; Sun, 24 Oct 2021 10:43:46 +0000 (UTC) Received: by mail-pj1-f52.google.com with SMTP id gn3so6103770pjb.0 for ; Sun, 24 Oct 2021 03:43:46 -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:references:mime-version :content-disposition:in-reply-to; bh=sVuIY4mcHQg8bRsDb3qKWmU0qyXXyyXmkLA+IGN0NwI=; b=HEjJqVTIQNzw08DhBqCfv+tW3y6hCDtv1GvmKg3QOHTIfhe1FL9g/e1ZjnLddvJjN4 cwQtsosJFODLfGm7u+V7ej5df/zRxGXg/wxHL8IMMHtwtVj/gphJcL68Lo7nWmILcvi3 d1ruUsyRY9aly2b9b2o3F3OVOf8vC7KUcmRzmf5ociYzHE24aGYI/slBxkFl3Lrb7u0N MtPnGMvWA9jwqxoPC+WiczNT2ttB2eLe46AWNMjqhcTJ1Uz3Te+qvzKu4FDZI9Ey2LuH wYAJ1iQbrCJ7W62k/mECx43Z75DWdTS3nhYJ99xO3nzyXN6ryHS2U92T+5D25wB17j8n uh6A== 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:references :mime-version:content-disposition:in-reply-to; bh=sVuIY4mcHQg8bRsDb3qKWmU0qyXXyyXmkLA+IGN0NwI=; b=YtKDMzz1tVpjJizchX2xXuKD5kfgZTmVZTqnfvbKolRAov704+jNzMjbNQS5DxTPfq T06ct6LTjlTqkNkEVNz/Sj40fEBbKRmuRejuywVnb96ZnJQPuDuInQp79lEdCgogciXi y0mn4G0MRj1kk+Q96XmHQy421+v+oFlxO3nq1RXz882nqK9EqxEbvezGyedyUUw1oPk3 o4A6bSyowr+ciOO/KQY4xCY+Sjy/UJW7BCu6oe+llEnlwiFv2lgI0J8+F+BFIvJ8ybwe yuVbNvJ9n4Wv0o0H2di3A7+StSsH9jcbGBt7umjSH+VkPJRrxTfYv497VAfIMablnq7S jR/A== X-Gm-Message-State: AOAM531ABsVc5yd1wGvumZnkf21BsPDt1/9SCBoHLB8qDCpe9hEIs9gF Wwl4Ensf82lUXFjccl5dOsI= X-Google-Smtp-Source: ABdhPJyOIMQKGc3n2+20uwpIqtCRlI0hZrSZ9mGL8vhus4eKnJL8qGsXCf/9i9We2/E3xf13XaWXqQ== X-Received: by 2002:a17:90a:c088:: with SMTP id o8mr8215040pjs.1.1635072225230; Sun, 24 Oct 2021 03:43:45 -0700 (PDT) Received: from kvm.asia-northeast3-a.c.our-ratio-313919.internal (220.195.64.34.bc.googleusercontent.com. [34.64.195.220]) by smtp.gmail.com with ESMTPSA id w5sm13043690pgp.79.2021.10.24.03.43.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Oct 2021 03:43:44 -0700 (PDT) Date: Sun, 24 Oct 2021 10:43:40 +0000 From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Vlastimil Babka Cc: Rustam Kovhaev , cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, djwong@kernel.org, david@fromorbit.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, gregkh@linuxfoundation.org, viro@zeniv.linux.org.uk, dvyukov@google.com Subject: Re: [PATCH] slob: add size header to all allocations Message-ID: <20211024104340.GA4370@kvm.asia-northeast3-a.c.our-ratio-313919.internal> References: <20211015005729.GD24333@magnolia> <20211018033841.3027515-1-rkovhaev@gmail.com> <20211020114638.GA378758@kvm.asia-northeast3-a.c.our-ratio-313919.internal> <1dfb7a79-3e66-a9fe-ee7c-1277d7ff5950@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1dfb7a79-3e66-a9fe-ee7c-1277d7ff5950@suse.cz> X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 357CD70000A0 X-Stat-Signature: a9y73cfhe4jwp63i9f6xh6gokk5ax565 Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=HEjJqVTI; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf27.hostedemail.com: domain of 42.hyeyoo@gmail.com designates 209.85.216.52 as permitted sender) smtp.mailfrom=42.hyeyoo@gmail.com X-HE-Tag: 1635072226-870465 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: On Thu, Oct 21, 2021 at 07:36:26PM +0200, Vlastimil Babka wrote: > On 10/20/21 13:46, Hyeonggon Yoo wrote: > > On Sun, Oct 17, 2021 at 08:38:41PM -0700, Rustam Kovhaev wrote: > >> Let's prepend all allocations of (PAGE_SIZE - align_offset) and less > >> with the size header. This way kmem_cache_alloc() memory can be freed > >> with kfree() and the other way around, as long as they are less than > >> (PAGE_SIZE - align_offset). > > > > Hello Rustam, I measured its impact on memory usage on > > tiny kernel configuration as SLOB is used in very small machine. > > > > on x86 32 bit + tinyconfig: > > Before: > > Slab: 668 kB > > > > After: > > Slab: 688~692 kB > > > > it adds 20~24kB. > > Thanks for the measurement. That's 3.5% increase. > You're welcome. > > > >> > >> The main reason for this change is to simplify SLOB a little bit, make > >> it a bit easier to debug whenever something goes wrong. > >> > > > > It seems acceptable But I wonder it is worth to increase memory usage > > to allow freeing kmem_cache_alloc-ed objects by kfree()? > > Not for the reason above, but for providing a useful API guarantee > regardless of selected slab allocator IMHO yes. > Mm.. that means some callers free kmem_cache_alloc-ed object using kfree, and SLAB/SLUB already support that, and SLOB doesn't. In what situations is freeing using kfree needed? Wouldn't this make code confusing? > > Thanks, > > Hyeonggon > > > >> meminfo right after the system boot, without the patch: > >> Slab: 35500 kB > >> > >> the same, with the patch: > >> Slab: 36396 kB > >> > > >