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 X-Spam-Level: X-Spam-Status: No, score=-18.2 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_IN_DEF_DKIM_WL autolearn=unavailable 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 71C1DC433DB for ; Mon, 21 Dec 2020 21:03:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2BA3F22AAA for ; Mon, 21 Dec 2020 21:03:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725885AbgLUVDj (ORCPT ); Mon, 21 Dec 2020 16:03:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725780AbgLUVDj (ORCPT ); Mon, 21 Dec 2020 16:03:39 -0500 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58A34C0613D3 for ; Mon, 21 Dec 2020 13:02:58 -0800 (PST) Received: by mail-lf1-x134.google.com with SMTP id a12so26954943lfl.6 for ; Mon, 21 Dec 2020 13:02:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xQaIP8214td2Fw8zqpizBbZjrLunzVtr25D3aarGH/c=; b=t/AjbS/YQMdRFPMVafWWmFWkStCgCVmBa3cgHKONPUDg5+sY8x5NxJMA+tuXyvNaW7 /NPyybg6sPYJnfTwvud1EZaF97julnUoMURZdA+pbYdwPKa/zBDfg8BH2WKij5gkiPLf J3ayUXNHgDtVtWjRl0FDSJ1UclI0a4Q6XtszUgCgths+x4ZOrXlipzuwgnwU9KzUa6Cr 2ZNYMJn3CZNKpe2ZawjqIBYq6o4jUTmgXYJt5ug/tfH7ZlPoCDYKBeJPNpDW77RLeLpO wuRhdrlCREw/5v5bga7EqnGH6nV8sWLjXP4uINgSHD2/e3dfwDTIdQf+qnK/kB7QlU1W miJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xQaIP8214td2Fw8zqpizBbZjrLunzVtr25D3aarGH/c=; b=J17i2mCJiWOg3V+NL+p/v7SWZZ0crdWw0BwVD5DFnPfTUPjJe0gVrGDIm1v83YWI2v adWuOyL0RGI70LymPzrKRwzWGwYseLLB6UBNwfdhDRcwPrncb6wUARRo5eM95AbNYVNH 389rPPTjB+8N7BRB2Q/wjSnT8sK2XtiWBqeJYdrbZAGutjGNl3al/6cM/5rUi4B6nl4N hGUKQjROuaCq3K61gIC8yzdpe+Sygfo5Vo+Quri4LGxVdinuwUS+Y/DcBnecTyCDbu81 vOX8dpcG4xwG63sp8NkWsQEk6W9PaqBX+v1QJ+lJTz+CD7ujEBx8u/29rkCo+s1fH/r3 vWiA== X-Gm-Message-State: AOAM5321/lb0xDQfnrmGT/jDdMAnBuvzjGUHgLNG1M31D1EBoGf6bllC rC26/OplMvlaw609y4sU+s3z1xMqeYfhNeKGDzLCug== X-Google-Smtp-Source: ABdhPJzvK9Qa8Wi48Cr0SpbjxsdBDEFBfT9XJP++rHDi0B72CsYsRdTUELd9Ae81QmUcqO3NCJZduJ8DyWwAkmmHd4A= X-Received: by 2002:ac2:46d4:: with SMTP id p20mr7102013lfo.299.1608584576264; Mon, 21 Dec 2020 13:02:56 -0800 (PST) MIME-Version: 1.0 References: <18669bd607ae9efbf4e00e36532c7aa167d0fa12.camel@gmx.de> <20201220002228.38697-1-vitaly.wool@konsulko.com> In-Reply-To: From: Shakeel Butt Date: Mon, 21 Dec 2020 13:02:45 -0800 Message-ID: Subject: Re: [PATCH] zsmalloc: do not use bit_spin_lock To: "Song Bao Hua (Barry Song)" Cc: Vitaly Wool , Minchan Kim , Mike Galbraith , LKML , linux-mm , Sebastian Andrzej Siewior , NitinGupta , Sergey Senozhatsky , Andrew Morton Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 21, 2020 at 12:06 PM Song Bao Hua (Barry Song) wrote: > > > > > -----Original Message----- > > From: Shakeel Butt [mailto:shakeelb@google.com] > > Sent: Tuesday, December 22, 2020 8:50 AM > > To: Vitaly Wool > > Cc: Minchan Kim ; Mike Galbraith ; LKML > > ; linux-mm ; Song Bao Hua > > (Barry Song) ; Sebastian Andrzej Siewior > > ; NitinGupta ; Sergey Senozhatsky > > ; Andrew Morton > > > > Subject: Re: [PATCH] zsmalloc: do not use bit_spin_lock > > > > On Mon, Dec 21, 2020 at 11:20 AM Vitaly Wool wrote: > > > > > > On Mon, Dec 21, 2020 at 6:24 PM Minchan Kim wrote: > > > > > > > > On Sun, Dec 20, 2020 at 02:22:28AM +0200, Vitaly Wool wrote: > > > > > 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. > > > > > > > > I don't want to use such open code for the lock. > > > > > > > > I see from Mike's patch, recent zswap change introduced the lockdep > > > > splat bug and you want to improve zsmalloc to fix the zswap bug and > > > > introduce this patch with allowing preemption enabling. > > > > > > This understanding is upside down. The code in zswap you are referring > > > to is not buggy. You may claim that it is suboptimal but there is > > > nothing wrong in taking a mutex. > > > > > > > Is this suboptimal for all or just the hardware accelerators? Sorry, I > > am not very familiar with the crypto API. If I select lzo or lz4 as a > > zswap compressor will the [de]compression be async or sync? > > Right now, in crypto subsystem, new drivers are required to write based on > async APIs. The old sync API can't work in new accelerator drivers as they > are not supported at all. > > Old drivers are used to sync, but they've got async wrappers to support async > APIs. Eg. > crypto: acomp - add support for lz4 via scomp > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/crypto/lz4.c?id=8cd9330e0a615c931037d4def98b5ce0d540f08d > > crypto: acomp - add support for lzo via scomp > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/crypto/lzo.c?id=ac9d2c4b39e022d2c61486bfc33b730cfd02898e > > so they are supporting async APIs but they are still working in sync mode as > those old drivers don't sleep. > Good to know that those are sync because I want them to be sync. Please note that zswap is a cache in front of a real swap and the load operation is latency sensitive as it comes in the page fault path and directly impacts the applications. I doubt decompressing synchronously a 4k page on a cpu will be costlier than asynchronously decompressing the same page from hardware accelerators. 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 X-Spam-Level: X-Spam-Status: No, score=-18.2 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_IN_DEF_DKIM_WL 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 7EFFFC433E0 for ; Mon, 21 Dec 2020 21:03:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C742B22AAA for ; Mon, 21 Dec 2020 21:02:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C742B22AAA Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id F41306B0036; Mon, 21 Dec 2020 16:02:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EF1786B005C; Mon, 21 Dec 2020 16:02:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E304E6B0068; Mon, 21 Dec 2020 16:02:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0119.hostedemail.com [216.40.44.119]) by kanga.kvack.org (Postfix) with ESMTP id CEF766B0036 for ; Mon, 21 Dec 2020 16:02:58 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 94CB78249980 for ; Mon, 21 Dec 2020 21:02:58 +0000 (UTC) X-FDA: 77618514036.07.eyes61_470c48e2745a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin07.hostedemail.com (Postfix) with ESMTP id 75CA41803F9AF for ; Mon, 21 Dec 2020 21:02:58 +0000 (UTC) X-HE-Tag: eyes61_470c48e2745a X-Filterd-Recvd-Size: 6404 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) by imf03.hostedemail.com (Postfix) with ESMTP for ; Mon, 21 Dec 2020 21:02:57 +0000 (UTC) Received: by mail-lf1-f47.google.com with SMTP id b26so17434946lff.9 for ; Mon, 21 Dec 2020 13:02:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xQaIP8214td2Fw8zqpizBbZjrLunzVtr25D3aarGH/c=; b=t/AjbS/YQMdRFPMVafWWmFWkStCgCVmBa3cgHKONPUDg5+sY8x5NxJMA+tuXyvNaW7 /NPyybg6sPYJnfTwvud1EZaF97julnUoMURZdA+pbYdwPKa/zBDfg8BH2WKij5gkiPLf J3ayUXNHgDtVtWjRl0FDSJ1UclI0a4Q6XtszUgCgths+x4ZOrXlipzuwgnwU9KzUa6Cr 2ZNYMJn3CZNKpe2ZawjqIBYq6o4jUTmgXYJt5ug/tfH7ZlPoCDYKBeJPNpDW77RLeLpO wuRhdrlCREw/5v5bga7EqnGH6nV8sWLjXP4uINgSHD2/e3dfwDTIdQf+qnK/kB7QlU1W miJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xQaIP8214td2Fw8zqpizBbZjrLunzVtr25D3aarGH/c=; b=heGXahLlVLdkidPtlJOWmc/Iq1LG2NfUb7RgHNv0grbG4usjXYOkuTePxLVuMAuvdy 5AK2o9IzQcwqOtAtNP//G/VbUNr/EQUT1lJX44x1Exf+OVfvNw4f4baZgV97w6pszxam SbTbp+WNjJJsSvW+LPN3YbRWhKWq92B6XPcmKIhbSBZaFmyj+OnVyJNPAS2ZYT0FWEGn Mo9L3l9IjnGUFe7ML4fs3h4KAemjv2rvL1pr5tI+v9+c2vBCcnyr0t+7QFzuBNpm3/bg HGDHvoJA2AuRSzmSqDPrUVa1cTy8o97pbevCbT6Do/D94tGkdRLmhZAhuF/Znq0RtS7k TMcA== X-Gm-Message-State: AOAM530Jc3Bn5odObnYCmpy6geVB6Vuoy7Ep5kFstg0NDT/TkVWD22qK SfAcXBtlwHkkicZIZAKOMRfLTYuWMdObrA75cLlj3g== X-Google-Smtp-Source: ABdhPJzvK9Qa8Wi48Cr0SpbjxsdBDEFBfT9XJP++rHDi0B72CsYsRdTUELd9Ae81QmUcqO3NCJZduJ8DyWwAkmmHd4A= X-Received: by 2002:ac2:46d4:: with SMTP id p20mr7102013lfo.299.1608584576264; Mon, 21 Dec 2020 13:02:56 -0800 (PST) MIME-Version: 1.0 References: <18669bd607ae9efbf4e00e36532c7aa167d0fa12.camel@gmx.de> <20201220002228.38697-1-vitaly.wool@konsulko.com> In-Reply-To: From: Shakeel Butt Date: Mon, 21 Dec 2020 13:02:45 -0800 Message-ID: Subject: Re: [PATCH] zsmalloc: do not use bit_spin_lock To: "Song Bao Hua (Barry Song)" Cc: Vitaly Wool , Minchan Kim , Mike Galbraith , LKML , linux-mm , Sebastian Andrzej Siewior , NitinGupta , Sergey Senozhatsky , Andrew Morton Content-Type: text/plain; charset="UTF-8" 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 Mon, Dec 21, 2020 at 12:06 PM Song Bao Hua (Barry Song) wrote: > > > > > -----Original Message----- > > From: Shakeel Butt [mailto:shakeelb@google.com] > > Sent: Tuesday, December 22, 2020 8:50 AM > > To: Vitaly Wool > > Cc: Minchan Kim ; Mike Galbraith ; LKML > > ; linux-mm ; Song Bao Hua > > (Barry Song) ; Sebastian Andrzej Siewior > > ; NitinGupta ; Sergey Senozhatsky > > ; Andrew Morton > > > > Subject: Re: [PATCH] zsmalloc: do not use bit_spin_lock > > > > On Mon, Dec 21, 2020 at 11:20 AM Vitaly Wool wrote: > > > > > > On Mon, Dec 21, 2020 at 6:24 PM Minchan Kim wrote: > > > > > > > > On Sun, Dec 20, 2020 at 02:22:28AM +0200, Vitaly Wool wrote: > > > > > 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. > > > > > > > > I don't want to use such open code for the lock. > > > > > > > > I see from Mike's patch, recent zswap change introduced the lockdep > > > > splat bug and you want to improve zsmalloc to fix the zswap bug and > > > > introduce this patch with allowing preemption enabling. > > > > > > This understanding is upside down. The code in zswap you are referring > > > to is not buggy. You may claim that it is suboptimal but there is > > > nothing wrong in taking a mutex. > > > > > > > Is this suboptimal for all or just the hardware accelerators? Sorry, I > > am not very familiar with the crypto API. If I select lzo or lz4 as a > > zswap compressor will the [de]compression be async or sync? > > Right now, in crypto subsystem, new drivers are required to write based on > async APIs. The old sync API can't work in new accelerator drivers as they > are not supported at all. > > Old drivers are used to sync, but they've got async wrappers to support async > APIs. Eg. > crypto: acomp - add support for lz4 via scomp > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/crypto/lz4.c?id=8cd9330e0a615c931037d4def98b5ce0d540f08d > > crypto: acomp - add support for lzo via scomp > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/crypto/lzo.c?id=ac9d2c4b39e022d2c61486bfc33b730cfd02898e > > so they are supporting async APIs but they are still working in sync mode as > those old drivers don't sleep. > Good to know that those are sync because I want them to be sync. Please note that zswap is a cache in front of a real swap and the load operation is latency sensitive as it comes in the page fault path and directly impacts the applications. I doubt decompressing synchronously a 4k page on a cpu will be costlier than asynchronously decompressing the same page from hardware accelerators.