Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3494672pxb; Sun, 24 Oct 2021 03:46:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUEgpWpD+ouX3Iw+iYj4AUebDjVl+hZCUkq1465QIZyHuj2UbhgB/1o8fRm29kQvkBNaoG X-Received: by 2002:a17:907:1011:: with SMTP id ox17mr5858471ejb.329.1635072390811; Sun, 24 Oct 2021 03:46:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635072390; cv=none; d=google.com; s=arc-20160816; b=PnqSDDIvgmcgqX3q78FhfvvZOftIdbyQyL6JP2tSF45bfBWYzYu3omeaUbk+ZTRs1S ov9FwVO8iZ+zSf4wJQOrCQ9kM25LFCjycIZTTNGX9y/5JLt+ITdlTTJaw84OX+fEKnKT SAD0ZUmGRkSNnXKuuYDffJguG7v+OH2NpG9OV66JfrBlyIerbJNquzwP32WAtiYBfXZ8 XTUffmvW9Gzh6bdD9sxTYmNpqZj02I0Yp7WPfIRwBwXkgf7g98t9YyarCVw1GJnm2pvr aCLOEfwjJRdsxr2jiYAGwES5fRbu59PYv1jzZFtvYCIP16MDhRK2TPERNW+Ug95wQ5Z6 KCGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=sVuIY4mcHQg8bRsDb3qKWmU0qyXXyyXmkLA+IGN0NwI=; b=hxRQPrIHEXHa9PNSdab+JXQlq9E/6Y+8Wn+6bHIVA877LH2aUq1MvvZ0p0eoXSUToM BR5VyoR3n2brWMZtiGQ3+uVhIkfvKrku1iUfEAwdt2N0UVHYP3e7J7BWan0J5SDXdYBi 70l82AyoIOlStCbmS9W2/EZo6nEm9mk31kD8z1M4sMe4seSGeqsXC7Rfmkp40ZUk2w6p 2fFivVWQps3c7mjWQBKmQ/oyh6jYRAMNF8Iv8+Rx9WxedtxrYxSjRWWhvtIEyjtVuuf7 l9B8jn3i+mkXNyNhIPO2pEcxHiNK3ZdRK+qeZ8ydyGsXQ2GD3J2yTa/h7tI2K9WNbFaf lskQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HEjJqVTI; 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 f8si25258485edf.472.2021.10.24.03.46.07; Sun, 24 Oct 2021 03:46:30 -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=HEjJqVTI; 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 S231540AbhJXKqH (ORCPT + 99 others); Sun, 24 Oct 2021 06:46:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231534AbhJXKqF (ORCPT ); Sun, 24 Oct 2021 06:46:05 -0400 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C498C061764 for ; Sun, 24 Oct 2021 03:43:45 -0700 (PDT) Received: by mail-pj1-x102a.google.com with SMTP id n36-20020a17090a5aa700b0019fa884ab85so9121212pji.5 for ; Sun, 24 Oct 2021 03:43:45 -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=ioSUJu4AbwnoAx0Og7E6FtiDQgZreglkh/Y2HhN1hHGRmhBm3/XSvXa7OfBfBxQSgf up1fPFVP3I0QITiGytMXMc4CBLty8x8bc+Ha+pmu0TW6PI9QjUkokszgmpHRdgC37HZE 7Vz+6rhRZVDMJrMZtO1Jq6Qh1B0j77QOPt/ppb2uexMG5eEL8hUXrALVJ2EJDuC3N1gB QvjwrJTVK4f1QpYmwHGNnF0pwYbKPvSk/FWmoVSmotj5fCgnIiT74S/dub36AIdhePYA CFAvYJuRqNPpN29vOG/+U6urO8M9derzEbMDwZTNtDUkFnZF502yKE+oByOY4HwigTfv OPdQ== X-Gm-Message-State: AOAM531lNlSTFhvI7kqtst29lQDVJOrW/8VYu31/iqEdDSePCTiieB3q daXvwaOFVN2AltzmfqZ8itw= 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> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > >> > > >