From patchwork Thu Jan 30 04:42:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 13954298 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75C45C0218A for ; Thu, 30 Jan 2025 04:45:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CB7422800BA; Wed, 29 Jan 2025 23:45:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C671D2800B9; Wed, 29 Jan 2025 23:45:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B2E342800BA; Wed, 29 Jan 2025 23:45:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 92E962800B9 for ; Wed, 29 Jan 2025 23:45:05 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 12D9C80739 for ; Thu, 30 Jan 2025 04:45:05 +0000 (UTC) X-FDA: 83062878570.29.D7A5F9E Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by imf07.hostedemail.com (Postfix) with ESMTP id 3E5AD4000B for ; Thu, 30 Jan 2025 04:45:02 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=I6PMWPHx; spf=pass (imf07.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.214.170 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1738212303; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=wp/wqKAz8lT7ubXbwwLLqI8OYR2q1r36R1/w+GLSRuc=; b=bxNqiPihECHTHThpPSG8nJdnOp7kkCpTSHZmxTcIOUKl3wZS175BCfl4CwFIGPPQ5QUotO Q3fksALmpRnO0LUXWlbDDRh+wFRHq1uP1C8aeeRhBWrfdrZw4tRkKePad4IDWIc38Vdf7E XfzPsmT6f2Hn2U9eoC0kDeD9bKJv7TU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1738212303; a=rsa-sha256; cv=none; b=U72D4IUmcPxHfV50qeMfBa7MMXVIXT3t6M0QAJKrnY7Nhb3395P3p2KxhSXzPxouYs5X/3 4XypaeEFTag7gIojpqiD+u+JAGbAKD6KjL/XVe9fevrF4kcVS+YNls0LNfJZjGXAFf63Sm ptHAlyRe1xO410rG1U5TmKHPYbWqe6w= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=I6PMWPHx; spf=pass (imf07.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.214.170 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-21c2f1b610dso8238575ad.0 for ; Wed, 29 Jan 2025 20:45:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1738212302; x=1738817102; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=wp/wqKAz8lT7ubXbwwLLqI8OYR2q1r36R1/w+GLSRuc=; b=I6PMWPHxgEQE3+HVRJoDCopA9hecpO15SNL94xxhlmXEBPZyaROcIvuG+8AbXeIVa0 dbMcZ/QM0icubZ4AgHeU/gpI4Z/R8bRd9YJBX0aaXbaQONVsIZkd5ppQZmLP3qzxXhVN VZ/P4TTiXYLrJVBLlalIyTelRlhKY0dgXww7s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738212302; x=1738817102; 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=wp/wqKAz8lT7ubXbwwLLqI8OYR2q1r36R1/w+GLSRuc=; b=eDw+wS6cd1bIz2shE4ugqsqwH5KIALGhl687PgDXXVS2QnWWdbUWhuyBKLbHoyQAjj vN1heZ7M0p43Oplp39abDaOIgWrl2fZmyFPReXtwY9i0JGlixRCJOabYArWuJd0UWCSk NNTqehC2RQ+mDfivF5UN2SjLWfMQ6wz4bhODQDoypPILb/OSY6ZW1UkzAbLTjNvBZsla ZfHDq+1ToXjQiOblFw5XhmdBlV0LJEZIlnrg749c85gGzl6NGun+4fZXwAtn9K5jH6nw 2rYOqvw6GzRt0OhYEsxrUIbbXT7AOTEfDgQ3JyVx9bkdlL+T0wH1qdeYxUAVJW6488vb C38Q== X-Forwarded-Encrypted: i=1; AJvYcCU/AHTsditMzraWoW2rb3a5sMto2lW39VG8dcL+eHJq5MhX9XsD9s6HHPq9STGKT9STCa4/udxv0Q==@kvack.org X-Gm-Message-State: AOJu0YyNBMZ66EMzEcZjO0E1oLOlwqSTxox5a6oYxHvjjGypO+lm/CG/ sx5rdgg8UKNSx6iuH5Bw3HhZI81RUMzSVZjq2c8WSHms/xQ2eeq/fydPbtfExg== X-Gm-Gg: ASbGnctDewy5G30slYG29lqZU2426DX4FRDNPc15IU2wKXBRwcJLcmhT8O47OWShiSA 38zTwYGj3NRO7+BiOdAU/O/jN2lciy2GI45yWy9bpMJw/6b04wM+yHv58mUBI84C9rUqW4UJX5Z pfWRO55azTrPPRRYNEBXLFBRzr19b11ZaKUc5bOVmfJ7Cj02KZiOe1VMYpDtzBIK4M4G7CrR7P+ 0siNm+deR/0YNKHGrCvOYArfW1MXXQilFHV6CRUY02jHdxfiRtPX5feHhbKELKOi1gHUbT8Kp92 15RjHLk/u0XXhuYGmg== X-Google-Smtp-Source: AGHT+IE+jTurSVbP5RHK0HJJXvm6F49R9W3yu8ODTcVpDcGP+GZ+KVPXpYzFtBPDke2AQKxhs0qqow== X-Received: by 2002:a05:6a21:33a4:b0:1e1:a9dd:5a58 with SMTP id adf61e73a8af0-1ed7a6c87f9mr9888284637.30.1738212301909; Wed, 29 Jan 2025 20:45:01 -0800 (PST) Received: from localhost ([2401:fa00:8f:203:d794:9e7a:5186:857e]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-72fe631bd9dsm427630b3a.14.2025.01.29.20.44.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Jan 2025 20:45:01 -0800 (PST) From: Sergey Senozhatsky To: Andrew Morton , Yosry Ahmed Cc: Minchan Kim , Johannes Weiner , Nhat Pham , Uros Bizjak , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Sergey Senozhatsky Subject: [PATCHv2 0/7] zsmalloc: preemptible object mapping Date: Thu, 30 Jan 2025 13:42:43 +0900 Message-ID: <20250130044455.2642465-1-senozhatsky@chromium.org> X-Mailer: git-send-email 2.48.1.262.g85cc9f2d1e-goog MIME-Version: 1.0 X-Stat-Signature: u6xnr54qtpdjw67m38g3nw99uxa7jsab X-Rspamd-Queue-Id: 3E5AD4000B X-Rspam-User: X-Rspamd-Server: rspam06 X-HE-Tag: 1738212302-699235 X-HE-Meta: U2FsdGVkX1+UT2nyvvWMR6GukJmdb72M8u75+URG3iox2pnYqlxB0mY7fweCaFgCpKLJcn7WTxqHPOzFfMQ6+k4p1NV/9RxVaX0ehNZFDRoVlJ7Npo4h0sI5WS6l0zlY0DignshkrwefpsvadLOIn4yTL/T8K7gfndlt2O23WsAsDk+XGiaq5rGEKZLNRnv2Zvm8p4p6yEexovm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to/1aIzJm/WLlSYbmOPmhLzi3HF/6gk= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000512, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: This is Part II of the series [1] that makes zram read() and write() preemptible. This part focuses only zsmalloc because zsmalloc imposes atomicity restrictions on its users. One notable example is object mapping API, which returns with: a) local CPU lock held b) zspage rwlock held First, zsmalloc is converted to use sleepable RW-"lock" (it's atomic_t in fact) for zspage migration protection. Second, a new handle mapping is introduced which doesn't use per-CPU buffers (and hence no local CPU lock), does fewer memcpy() calls, but requires users to provide a pointer to temp buffer for object copy-in (when needed). Third, zram is converted to the new zsmalloc mapping API and thus zram read() becomes preemptible. [1] https://lore.kernel.org/linux-mm/20250127072932.1289973-1-senozhatsky@chromium.org v1 -> v2: - Tweak cmpxchg loop (Uros) - Addressed feedback provided by Yosry Sergey Senozhatsky (7): zsmalloc: factor out pool locking helpers zsmalloc: re-shuffle zs_pool members zsmalloc: factor out size-class locking helpers zsmalloc: make zspage lock preemptible zsmalloc: introduce new object mapping API zram: switch to new zsmalloc object mapping API zram: add might_sleep to zcomp API drivers/block/zram/zcomp.c | 6 +- drivers/block/zram/zcomp.h | 2 + drivers/block/zram/zram_drv.c | 28 +-- include/linux/zsmalloc.h | 8 + mm/zsmalloc.c | 379 ++++++++++++++++++++++++++-------- 5 files changed, 313 insertions(+), 110 deletions(-) --- 2.48.1.262.g85cc9f2d1e-goog