From patchwork Wed Feb 7 06:57:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 20041 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2047000dyb; Tue, 6 Feb 2024 22:58:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IFabi/M92iA9Obn5hiBXoUA/0cwYOLdnYkOJgkdctlMIWSHgi9ihH3NpuYt83qpZbdkPVa2 X-Received: by 2002:a05:6214:c67:b0:68c:aecf:a3db with SMTP id t7-20020a0562140c6700b0068caecfa3dbmr6239129qvj.26.1707289121100; Tue, 06 Feb 2024 22:58:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707289121; cv=pass; d=google.com; s=arc-20160816; b=qL7uxUQlTgKmaXQfmJZRcnmKowHNPZ8q9qPhSow+TRRSpVwCO9EPT5vMU3cZ2XUWaR PwiUwHnl816lqEinRHfpfwnbDuML3RSeFeo2/m4SOSIrjNOr9FNzpv2GAE/8T6UgNYd4 2IaAePJwdJiwppvba8qBPTYqB146OvESXt0ubaLFmz1PjDpCLMrCfyEKn3ZelXDBudSe OTA1G0p//NQeF70akIv58LPuLBMeWVjtTsN1E2w+61ibKqfjRghNLT5idFoLauBDE+wH lZqfVc1CgRVtbvtdsdy8zRwooQOfkw7Ne7rYrOPXpLgXkkh/P7B2J28J62LD4nlQbZaa jNYQ== 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=cYFjhvYCP2RiTw8+dMj3t3RSsArPV3K6tWoRxqtAA/Q=; b=M3m7Z4sUTRxcIj5/3JbmvSkDWkPRcgpgoqPsaa0Swkx4VZScnfOdG9i3spCVVsDLkh uhrje/+kycbjsxbWpdIxbhmp3D8rqbmzqJcqE9ExqdCcsN1baezblRQ+jKM0Yv7adf5d HxLcMtQ+cnByOwHrCCOaGWVJsrswMAtiNyFUgblBVy3SXbsye8auJv6W4Aj2pA7VVW2i k3sgKLa8r122MxewWskjJKrQ/zxHVwXDgI6ve6gKvwDezLrrEfb0pOVP4LTB7hCOzgyU lp8uv4F5IPLE+x/o1/2n/HXviK+250pPdsxiL6SnyTVpqLkdEg8MYxAswB+NeLIMbrO/ POQg==; 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56046-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCX3x+NMoX4qIWQR0BrMN493DPS6WIYucLKeYOHujE+Toly/CQV2s1RiM0OqKmqoEMGkodzfY6YD0atWe1TlkuU3TGEHjg== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id ei18-20020ad45a12000000b0067ee3520aefsi568503qvb.151.2024.02.06.22.58.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 22:58:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56046-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; 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-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56046-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id DE36B1C2560B for ; Wed, 7 Feb 2024 06:58:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 810CB200BF; Wed, 7 Feb 2024 06:58:06 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790222397546297597 X-GMAIL-MSGID: 1790222397546297597 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(-) Signed-off-by: Sergey Senozhatsky