Received: by 2002:a05:7412:2a8a:b0:fc:a2b0:25d7 with SMTP id u10csp132036rdh; Tue, 6 Feb 2024 23:05:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IFFWKRtlDy3PgC/FhZV4MCGPPIAJhz0A++EFWq3icXzqS3AoGaFAJ0omo6n/dDlf3SpEcYm X-Received: by 2002:a05:6808:21a3:b0:3be:bb86:c1f3 with SMTP id be35-20020a05680821a300b003bebb86c1f3mr6251661oib.44.1707289510332; Tue, 06 Feb 2024 23:05:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707289510; cv=pass; d=google.com; s=arc-20160816; b=SGP4T7yOVQ94CWMlP2wSU4//RldZ1dYBDidrQ8y8pwSfvcrxGSA7qy+14aJCraO5LA SFJX9114P9GxGjp/9qB9C2hingRcusG3FojRZloh0u1U+spP8HLryP0c2txL4zXlevKb XV1h4WLvLy0FWK15E+tcwrQG93UtAbeOv9QG5x7mcO2noX6JWH4VlVRKrIsCSrBp5Nwy FGRhEbL9BRtLUnZQ9zjQYAyJ05UR65GlKMdVMUkWRf9JB1CT/5Fzy4yd1U4Lnj/QeN2B cymeLwUEFRoIvyCLNbhY1F/GWrHwXQsMqsKxI9oOwTO2CQXH54pxWZy2hbxrYuh4PmGI zP+g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=Tjfy54B6+Jm7MlmeoV5+p4SaY3yr3KlOWnWh/R3pw/Q=; fh=tH+BC0TgwwGhhptLqrnZrYtCPCT6giyl9HeqziNkYxs=; b=bFQHe0AfMakXBFmroI1qQ4aagPU+avIqjzM0B9td/GfxG3FscgRAYEL4tjosDBMXaI CP/jmu6hOFY+79AFKlDehGhbp+t92y+nDr2aUt+A6nMfGT49gySZJEmScre+jZRL1w+l 6DUMfeMBNIrYqgiX1vRh1oyrH8EBdLTV0OT1biaenK7ItYFgAZ60PChKK7ZvaSo2vZdF 3ipWb0DBpN+GQDt4XtTE/8X+qDE2z6NO+lRC+mM0jPnKUyHBfiFSAGurIRQG8FOnS4u+ 5nkcEdJ5e9uXankX8CGMXuZS0dTK3I9+SjEfZ4RoU42Jpj6gHLdRU3fzstQ+oQyvPhAK 1t8w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=MfeQX4J+; 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-56046-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56046-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCWdKCZ99+UUP1+G8wz7TPDaALMLKOa6gqI5RNlkNW2MiSY+qmJkVbwFzp1unUV0iYhf3K6LOST79ZsMG0QLYYLZdJj4ajfCSZxY0OAqPw== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id gx20-20020a056a001e1400b006e04716e436si862781pfb.216.2024.02.06.23.05.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 23:05:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56046-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=MfeQX4J+; 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-56046-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56046-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 2503328C76D for ; Wed, 7 Feb 2024 06:58:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 955241F608; Wed, 7 Feb 2024 06:58:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="MfeQX4J+" Received: from mail-yb1-f176.google.com (mail-yb1-f176.google.com [209.85.219.176]) (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 ED4B41CD30 for ; Wed, 7 Feb 2024 06:58:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707289083; cv=none; b=LDbPI15X4U7FWmYah5814TpQUohd+0owptfEbzE90TK2a12IVPf7047DEkPkrdJj2foP+FMJF83ArEWtqTnsmefYHbTZdOhWFu84KovZ10P2D2A9h2mmVPKUbHtMDL+aNbUhsDDziWYakZ6Ssg+Ww3DySr42I3V/dInuWTX0y0I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707289083; c=relaxed/simple; bh=rCZ9HSGtLLD4caLOi+C1H8AptWnr7xurWcFkoFTjU1w=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=eJrJEbpwnw+4jLzqX9eUbLg+wmXGOaGencEUm5aijNTUfoTBMyfI5mZr7ihdsuvQHBM478N6IF7VvVzy5icmvi/H2hLgPaQg7NRhgPdL6jrpoSgAGq3BQoskmyn2zy7/xjaQVcnU0pkZjtRhiOP/LwIqWGt3t+72RIbNz8bSH4Y= 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=MfeQX4J+; arc=none smtp.client-ip=209.85.219.176 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-yb1-f176.google.com with SMTP id 3f1490d57ef6-dc730e5d88cso213745276.2 for ; Tue, 06 Feb 2024 22:58:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707289080; x=1707893880; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Tjfy54B6+Jm7MlmeoV5+p4SaY3yr3KlOWnWh/R3pw/Q=; b=MfeQX4J+50Q+ag2o5vzzyEtnDwVDIINPiKv4QiLy11lxUI83QtjeWW1+AMOA6jN4r0 jsSgFnJsuh1RtTwjsR7mIcesGHpSIqnT7Nmkrmsaf+HB+nsrIxuow1vT0mPU96zkyN8Z w6azVL2BzPEHxB28B4dWbKXPgWUMiMSjQXg/Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707289080; x=1707893880; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Tjfy54B6+Jm7MlmeoV5+p4SaY3yr3KlOWnWh/R3pw/Q=; b=OJMqUL4Ri9WvqUZN3EzUi64kSOswGtwYEh1FzexEdOMNyUtc6XGTs87JEWKO1sc4o4 +XlTR87nYKnJ6VsJM9Z7vW2ygqYausH4w+RfAO/D8eWoOyMAgMGOyaOK5qtUFYlgqyfL ONV3ZJO9EVjID6yYxU+4dLpvJeGwFDVLSwQv8gsr8rrqz3JOpBdoUCKt+q2dF5yfZdz5 xNoWgclTKHCoHMOGnhhJEPM0QVI2JSuf+aUrmNwuF7wu69K+XA6rRefG1YkLxlcmfQAU yyQfsdcFX6Cd8UH4/8ypI+GDuiAfTge9uJKy2YnIVY7RdMqeMQHRu7ShMsIpUfP8zrI+ qaOg== X-Gm-Message-State: AOJu0YwMZ9xme2QGBa2A7uWwvC9rl6IaMmUWDeV/stPtnRT6n85gz1w5 EJ9h9WJnRZaVYOqXhQTaWfzv78vf/fmVKxf9Z1zWPKRq6P/ol/nlpbsRTXilTA== X-Received: by 2002:a05:6902:1a45:b0:dc6:b8f5:50ae with SMTP id cy5-20020a0569021a4500b00dc6b8f550aemr4421214ybb.32.1707289079959; Tue, 06 Feb 2024 22:57:59 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCW0zpFxQmjQG8MCNugXs8T9eOKOGkwr3Fe3UTCLKl3sSP4+a0vNh1XuKHHW5agD9D1LTYrg91AHdng2rpQiRJrzXdZtQgTITvaLSFetHFjk3/ZfKxeHMU5IowymtMTkelrCsGTsxATuh03xQ8S6SsQA/3oGqqy8hL92FGaz0Ubl0zw= Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:aa4c:2868:935:7ac6]) by smtp.gmail.com with ESMTPSA id jw15-20020a056a00928f00b006e03ac84d53sm672576pfb.193.2024.02.06.22.57.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 22:57:59 -0800 (PST) From: Sergey Senozhatsky To: Minchan Kim , Andrew Morton Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Sergey Senozhatsky Subject: [RFC][PATCH 0/2] zram: decouple comp stream and comp buffer Date: Wed, 7 Feb 2024 15:57:10 +0900 Message-ID: <20240207065751.1908939-1-senozhatsky@chromium.org> X-Mailer: git-send-email 2.43.0.594.gd9cf4e227d-goog Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit RFC We keep compression work memory buffer per-comp stream (which is per-CPU), but we don't need that many buffers, because on each CPU only one compression backend can access work memory at any given time. Hence the patch series moves compression work memory to a dedicated per-CPU area, reducing the amount of memory we allocate for those buffers. For instance, assume a 12 CPUs system, 2 compression streams per-CPU (a default and one for deferred recompression). Before we'd allocate 12 * 2 * 2 pages, after we'll allocate 12 * 2 pages. NOTE: The series stops short of moving comp buffers to a global per-CPU area, which all zram devices can share. Compression backends use CPUs exclusively (disable migration and CPU hotplug), so in theory comp work memory can be in global per-CPU data. This can reduce memory usage on systems that init numerous zram devices. E.g. instead of num-zram-devices * num-cpus buffers we'll allocate only num-cpus buffers. Sergey Senozhatsky (2): zram: do not allocate buffer if crypto comp allocation failed zram: move comp buffer to a dedicate per-CPU area drivers/block/zram/zcomp.c | 118 +++++++++++++++++++++++++++++----- drivers/block/zram/zcomp.h | 24 +++++-- drivers/block/zram/zram_drv.c | 32 +++++++-- drivers/block/zram/zram_drv.h | 1 + include/linux/cpuhotplug.h | 1 + 5 files changed, 151 insertions(+), 25 deletions(-) -- 2.43.0.594.gd9cf4e227d-goog