Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp23043lqr; Tue, 4 Jun 2024 19:17:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXI8Uxm7yiKHIsKyQ2j20gxSU+hBWmHHy2COb+flLK00J2pzSevMnKPQ6jFmgysWaNbdCFY923bkxQGFo2NRA1NwXNp+ZIYWxn4o3OTAA== X-Google-Smtp-Source: AGHT+IHXjknkCNMPOIfFVpf2fd4cw8/KZDBbC1fa7hy54Ll7JZxWkyngBn2dBZIb0v9vqlCwCL65 X-Received: by 2002:a05:651c:a05:b0:2e9:821a:82fb with SMTP id 38308e7fff4ca-2eac797fb55mr7433801fa.6.1717553835230; Tue, 04 Jun 2024 19:17:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717553835; cv=pass; d=google.com; s=arc-20160816; b=saB4bBASnY3k3ofsO2X24Cyi4GRmzHCvg+F7Ru2eNq/CIX3C15yOvMptsKgFJW5cGE JQA1tOTvV9dw2GcwP38EY68t2jJ2zvMI+q+Wj4oCo8mf7loyvBPY9ZNvhYU3r7FW3QEJ OgGdFD7llFnyE0ro4NryES5w8JonT8x3rY0MOGGX+glNauocr0AniXWjEIBvFJPQ7iv/ kn17+2d2nHZPXm7Cda03qNwolYEMe7Auo3pau73SNKnsPdCIVcdpb0Pp9CQnp9aljiH3 u/bJMahB22LBD9aegImWCLP+PoAmjyudpF+Py1NvWUzkLlYFa+8/Ada7Ra9rNKfJ9AOG DE+g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=mmUqGT6R1ALyKLT05MMVBNync2sESvjPRIFmm8CcRyI=; fh=zs7pxEf90Qhx3UwaLFF6a+JODgzLlGaPxxzmU5jkvPU=; b=EHmX8Jzz2XX/tC96RqSJZSHi6yk1UEMJd6TV4HqZqdZG04oSq2McQsE9xzsm1YhJmX dw7v0JTloUTYXVCNKeu5jtlHbAcZjQpUR47F1E8rUUdZ06ZWDKWQjTojtUtNcB6QQWpa WXaMrcT7ALMuW6KoimO2yHOt9MjyGu3uV+pVNcESMespYkPB4G7DoETdDIWMzcaO8/nD 5aeHeL3IYQMWTo0DTLTEFJOk4V1CW4Wn1YzReiYAoROWL0G88FschZSEQGN3faVR/0sp MuK2I4PVfvYcye6tDTJukz7MuLzu7I8FLYpYImPAEP6TRnhupwkkUGyzvUqkzK0ECzrj mAxA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="l87G/C95"; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-201672-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201672-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a31c62d7esi5641886a12.328.2024.06.04.19.17.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 19:17:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-201672-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="l87G/C95"; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-201672-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201672-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id EC1C51F253D2 for ; Wed, 5 Jun 2024 02:17:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0EDE95338D; Wed, 5 Jun 2024 02:17:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="l87G/C95" Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E080F1EB36 for ; Wed, 5 Jun 2024 02:17:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717553828; cv=none; b=roM8sEtFDz04ePjICoe9AA1GZRHZ47gNlW7rVH+ZOUCWyd2zAAvwjUn3i6iswiESuvXJpT5mwo9tcfmaRbcld7GM58YhAhwgVQZl2Ge2HN8q6G58xD17XVyBCaNddOypEwqwgFrBJYk/cPqepgkmEengpqg5AJq6Nuhgyfgxi/A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717553828; c=relaxed/simple; bh=MLfPfaoRWzUtkJbb03QMNFwwSc4Jj5l8BHZun+Zm9tA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=npLqqPBHAY1IUPfPrCokFniXzWA0DewAVi96j1zVoKl3j47WZbgsib8VKx2ipqduiGe9zyQPx/rGh/A1CWEn3z7F3qzcotzr0qmghLwsQSe4Pw0r1J3XV5VeXzCszjTooTCVWlC+PUBahjxXeqfTDhzftc5MKd79HQtb1k3CvYM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=l87G/C95; arc=none smtp.client-ip=209.85.215.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-6c5a6151ff8so1403804a12.2 for ; Tue, 04 Jun 2024 19:17:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1717553826; x=1718158626; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=mmUqGT6R1ALyKLT05MMVBNync2sESvjPRIFmm8CcRyI=; b=l87G/C95InJSUvSyfWONXhMOKgPY/3LUnMn8iG52nRdPrWeh+ARSF1VSbfSNCFT1/S gIPepG8JpCNsj48tbNFpAgjGmUBQso9lm7GWVEImNo5F/9dMmXw2wVE4x/etSsle4yav lx3o/PG/pSefS5pAHoxt0iXnDh4qRMowT8nUA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717553826; x=1718158626; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=mmUqGT6R1ALyKLT05MMVBNync2sESvjPRIFmm8CcRyI=; b=DWCTYDyCyV9qSSIm5U/D9dEyHQ0iN5CotRg+p0EofVRTiCLTavR7298GoQV5WDpnPb X+ysKbH+6f+oPT8aIzVb740ZQaIpjD+hL7bau5p7jLTYdMuN+55LlY+u2Id2R0aUFpn3 XKVcMwhkbXoKcjYKUQhFVZAD7zrlde8m639wYmdMlcqGuhhge6SzTEVriD18NYbusp09 cZGQZ6uo/8yb4/AdZId7bpMZ4GC4o6mfabcxo+MjH68qZuleh2p44qr4cNKc7vmiDsOf tNFL7RFJ9WpHTUZqB2vUVUozm5waODYj4O5roUQiaYkSFGR+le3Vn0A5pNs63iuqweI1 qKTw== X-Forwarded-Encrypted: i=1; AJvYcCVJY+YdOLFLbT2POtPkn02hAZBBLZKdOJcOOYGOkZINfxP0ygDz2nbJuG+JMvMu4ugCltPBtduWSXwO5L/eIAmgaip+ragkmjHnTxJn X-Gm-Message-State: AOJu0YxlRFZc3raRAFpTOSO0g5/lBjWSnyt5USdvxSHv6vfH0DNw+/S+ X0JLxtKoGr71wSodY3O7+3QjhrxIu3BWSXZQ0XiuR5KgWd32DSN1rcxNOzW+zg== X-Received: by 2002:a05:6a20:7348:b0:1af:f8e7:76d4 with SMTP id adf61e73a8af0-1b2b6ed9cbemr1830288637.18.1717553826123; Tue, 04 Jun 2024 19:17:06 -0700 (PDT) Received: from google.com ([2401:fa00:8f:203:72fe:f923:2f3c:6cd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f6323dd73esm90373315ad.158.2024.06.04.19.17.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 19:17:05 -0700 (PDT) Date: Wed, 5 Jun 2024 11:17:01 +0900 From: Sergey Senozhatsky To: Yosry Ahmed Cc: Andrew Morton , Minchan Kim , Sergey Senozhatsky , Vlastimil Babka , David Rientjes , Christoph Lameter , Erhard Furtner , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: zsmalloc: share slab caches for all zsmalloc zpools Message-ID: <20240605021701.GB11718@google.com> References: <20240604175340.218175-1-yosryahmed@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240604175340.218175-1-yosryahmed@google.com> On (24/06/04 17:53), Yosry Ahmed wrote: > Zswap creates multiple zpools to improve concurrency. Each zsmalloc > zpool creates its own 'zs_handle' and 'zspage' slab caches. Currently we > end up with 32 slab caches of each type. > > Since each slab cache holds some free objects, we end up with a lot of > free objects distributed among the separate zpool caches. Slab caches > are designed to handle concurrent allocations by using percpu > structures, so having a single instance of each cache should be enough, > and avoids wasting more memory than needed due to fragmentation. > > Additionally, having more slab caches than needed unnecessarily slows > down code paths that iterate slab_caches. > > In the results reported by Eric in [1], the amount of unused slab memory > in these caches goes down from 242808 bytes to 29216 bytes (-88%). This > is calculated by (num_objs - active_objs) * objsize for each 'zs_handle' > and 'zspage' cache. Although this patch did not help with the allocation > failure reported by Eric with zswap + zsmalloc, I think it is still > worth merging on its own. > > [1]https://lore.kernel.org/lkml/20240604134458.3ae4396a@yea/ > > Signed-off-by: Yosry Ahmed Makes perfect sense, thanks. Reviewed-by: Sergey Senozhatsky