From patchwork Sun Dec 20 00:22:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vitaly Wool X-Patchwork-Id: 11983735 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC2B7C4361B for ; Sun, 20 Dec 2020 00:22:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 37E7023A00 for ; Sun, 20 Dec 2020 00:22:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 37E7023A00 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=konsulko.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4D7DF6B005C; Sat, 19 Dec 2020 19:22:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 488AA6B005D; Sat, 19 Dec 2020 19:22:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 329C06B0068; Sat, 19 Dec 2020 19:22:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0083.hostedemail.com [216.40.44.83]) by kanga.kvack.org (Postfix) with ESMTP id 12C126B005C for ; Sat, 19 Dec 2020 19:22:45 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id D62441EF2 for ; Sun, 20 Dec 2020 00:22:43 +0000 (UTC) X-FDA: 77611759806.19.trees84_4c094ab2744a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id B19811AD1B9 for ; Sun, 20 Dec 2020 00:22:43 +0000 (UTC) X-HE-Tag: trees84_4c094ab2744a X-Filterd-Recvd-Size: 4531 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) by imf47.hostedemail.com (Postfix) with ESMTP for ; Sun, 20 Dec 2020 00:22:43 +0000 (UTC) Received: by mail-wr1-f43.google.com with SMTP id 91so6984194wrj.7 for ; Sat, 19 Dec 2020 16:22:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=veEGZkmRRU+6E+UwbrDFrTo1q54Pe0TuW7IheShsqgA=; b=MAVOTwEQw8QbqgDyQ46hHNZrl6HqZHhF7eH/57yIAv2P2FfzIK5ddlSCeqtJs+SRhE KIrPzqVY/xTn1cbwo4Qp6RXhapIy+O0MJzYrDdAcENKglMxRuoVzHl0Q25tGY6wkAnJe pOykfWDvLZSelj7XD+F67fiJ1V8bUaDGG4nP8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=veEGZkmRRU+6E+UwbrDFrTo1q54Pe0TuW7IheShsqgA=; b=Zxrl/wzp4WyczpsR2hf449wuzGt6bTGntONFCewUH1ShODGvOZWzDhDLw/7OiwqwXM Vyg4VH1WuLOM7SAXBlYrqfa9/nkzCo54Hv4CXSw8bs3BJ1Vp9Flt0IzhrfiHDdVul4qA TAcN0zUky+A3yH4310mkiDyNqdVXpDFTasTsYQNFQ6kqYqt472IomB3NJYHPOsZiHHu0 AHCmNYA0g5HBB7uJmGUEmk/WN+QaP0JfzRL/JSW6N/F7i7sH5QzWJJCi7WPcx5joon7Z qSqyfpBbkbKxoDQn6Z0VODjHG4B8fE+iW8bbGfasp3YO6ORhL3PPJQutJeZJ+cTxm5sA M5Fg== X-Gm-Message-State: AOAM5329HWBxxN/8Qtsc43FdbD0z1UJkXBpR9AsGp8wOOSl6CYf/Chj5 p/TSHDQn75A29DQJYzI36eR6vA== X-Google-Smtp-Source: ABdhPJyeafvDyYyRQYfUxsG6iRQp0MQssaNwO8Q3S3gSvjF7fMxIUBR3ATGnkzE/TykBNVBdTLh3yQ== X-Received: by 2002:adf:97dd:: with SMTP id t29mr11324606wrb.357.1608423762138; Sat, 19 Dec 2020 16:22:42 -0800 (PST) Received: from lootbox.konsulko.bg (lan.nucleusys.com. [92.247.61.126]) by smtp.gmail.com with ESMTPSA id x13sm20635830wrp.80.2020.12.19.16.22.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Dec 2020 16:22:41 -0800 (PST) From: Vitaly Wool To: Mike Galbraith , LKML , linux-mm Cc: Barry Song , Sebastian Andrzej Siewior , Minchan Kim , NitinGupta , Vitaly Wool Subject: [PATCH] zsmalloc: do not use bit_spin_lock Date: Sun, 20 Dec 2020 02:22:28 +0200 Message-Id: <20201220002228.38697-1-vitaly.wool@konsulko.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <18669bd607ae9efbf4e00e36532c7aa167d0fa12.camel@gmx.de> References: <18669bd607ae9efbf4e00e36532c7aa167d0fa12.camel@gmx.de> MIME-Version: 1.0 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: zsmalloc takes bit spinlock in its _map() callback and releases it only in unmap() which is unsafe and leads to zswap complaining about scheduling in atomic context. To fix that and to improve RT properties of zsmalloc, remove that bit spinlock completely and use a bit flag instead. Signed-off-by: Vitaly Wool --- mm/zsmalloc.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 7289f502ffac..ff26546a7fed 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -876,22 +876,25 @@ static unsigned long obj_to_head(struct page *page, void *obj) static inline int testpin_tag(unsigned long handle) { - return bit_spin_is_locked(HANDLE_PIN_BIT, (unsigned long *)handle); + return test_bit(HANDLE_PIN_BIT, (unsigned long *)handle); } static inline int trypin_tag(unsigned long handle) { - return bit_spin_trylock(HANDLE_PIN_BIT, (unsigned long *)handle); + return !test_and_set_bit(HANDLE_PIN_BIT, (unsigned long *)handle); } -static void pin_tag(unsigned long handle) __acquires(bitlock) +static void pin_tag(unsigned long handle) { - bit_spin_lock(HANDLE_PIN_BIT, (unsigned long *)handle); + preempt_disable(); + while(test_and_set_bit(HANDLE_PIN_BIT, (unsigned long *)handle)) + cpu_relax(); + preempt_enable(); } static void unpin_tag(unsigned long handle) __releases(bitlock) { - bit_spin_unlock(HANDLE_PIN_BIT, (unsigned long *)handle); + clear_bit(HANDLE_PIN_BIT, (unsigned long *)handle); } static void reset_page(struct page *page)