From mboxrd@z Thu Jan 1 00:00:00 1970 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A7E0C433F5 for ; Tue, 28 Sep 2021 22:47:27 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 94C5561206 for ; Tue, 28 Sep 2021 22:47:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 94C5561206 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id DB4EB900003; Tue, 28 Sep 2021 18:47:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D3DF7900002; Tue, 28 Sep 2021 18:47:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB77B900003; Tue, 28 Sep 2021 18:47:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0099.hostedemail.com [216.40.44.99]) by kanga.kvack.org (Postfix) with ESMTP id A7D9A900002 for ; Tue, 28 Sep 2021 18:47:25 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 532CC3017A for ; Tue, 28 Sep 2021 22:47:25 +0000 (UTC) X-FDA: 78638470050.23.608C036 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf04.hostedemail.com (Postfix) with ESMTP id 0286E50000B6 for ; Tue, 28 Sep 2021 22:47:24 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id ECEFD6101A; Tue, 28 Sep 2021 22:47:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1632869244; bh=YVa1bRvFA7Pi4yw3NBJ8qvePYI+yBsHheM/WIfDq4YY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=mty7WK6EGx92BIzTrbb/tRP1PXW1zYYecsQKMgQWHFN8PqM6HEfh3SSByP3N+V0CV 6khIkBHpngG/fIJwTSlLXpyORg0ZdjNyLT9gOpapkkuRg50zyK5tmNtqThSy8DcF9H pcAY64fUTpPAgS6EihrEgHFjEczM+4OXtZklobSo= Date: Tue, 28 Sep 2021 15:47:23 -0700 From: Andrew Morton To: Sebastian Andrzej Siewior Cc: Minchan Kim , linux-mm@kvack.org, Thomas Gleixner , Mike Galbraith , Mike Galbraith Subject: Re: [PATCH] mm/zsmalloc: Replace bit spinlock and get_cpu_var() usage. Message-Id: <20210928154723.1b0577818143734653d9b129@linux-foundation.org> In-Reply-To: <20210928084419.mkfu62barwrsvflq@linutronix.de> References: <20210923170121.1860133-1-bigeasy@linutronix.de> <20210928084419.mkfu62barwrsvflq@linutronix.de> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 0286E50000B6 X-Stat-Signature: wqexhnyct9pibpxq5bzhfsa859qijabe Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=mty7WK6E; dmarc=none; spf=pass (imf04.hostedemail.com: domain of akpm@linux-foundation.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-HE-Tag: 1632869244-859367 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, 28 Sep 2021 10:44:19 +0200 Sebastian Andrzej Siewior wrote: > From: Mike Galbraith > > For efficiency reasons, zsmalloc is using a slim `handle'. The value is > the address of a memory allocation of 4 or 8 bytes depending on the size > of the long data type. The lowest bit in that allocated memory is used > as a bit spin lock. > The usage of the bit spin lock is problematic because with the bit spin > lock held zsmalloc acquires a rwlock_t and spinlock_t which are both > sleeping locks on PREEMPT_RT and therefore must not be acquired with > disabled preemption. > > Extend the handle to struct zsmalloc_handle which holds the old handle as > addr and a spinlock_t which replaces the bit spinlock. Replace all the > wrapper functions accordingly. > > The usage of get_cpu_var() in zs_map_object() is problematic because > it disables preemption and makes it impossible to acquire any sleeping > lock on PREEMPT_RT such as a spinlock_t. > Replace the get_cpu_var() usage with a local_lock_t which is embedded > struct mapping_area. It ensures that the access the struct is > synchronized against all users on the same CPU. > > This survived LTP testing. Rather nasty with all the ifdefs and two different locking approaches to be tested. What would be the impact of simply switching to the new scheme for all configs? Which is identical to asking "what is the impact of switching to the new scheme for PREEMPT_RT"! Which is I think an important thing for the changelog to address?