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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E923C433EF for ; Thu, 27 Jan 2022 15:54:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 808826B0089; Thu, 27 Jan 2022 10:54:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7900D6B008C; Thu, 27 Jan 2022 10:54:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6315A6B0093; Thu, 27 Jan 2022 10:54:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay036.a.hostedemail.com [64.99.140.36]) by kanga.kvack.org (Postfix) with ESMTP id 4CC366B0089 for ; Thu, 27 Jan 2022 10:54:20 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 1A2E4120AB9 for ; Thu, 27 Jan 2022 15:54:20 +0000 (UTC) X-FDA: 79076513880.02.0949AEB Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) by imf13.hostedemail.com (Postfix) with ESMTP id AE49320011 for ; Thu, 27 Jan 2022 15:54:19 +0000 (UTC) Received: by mail-lf1-f43.google.com with SMTP id z19so6146015lfq.13 for ; Thu, 27 Jan 2022 07:54:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=tEdIw9wvH2zzikieh/eX5e+Rn+l7enMUtCDEVtvQdrk=; b=RFckaGUnFbqIPS+Q3iHJdF5OVea6d/84A+JBwxVoCixniwESqyDafZ3gFBKPIzaPrO 8TSOKZ8Jp4DbbQkgIq0OIxwnbnNzUcMY2U5VBYn3mxflXD9WRG+qxFBn3BVNEIPYLLIA FyTGNk8T2sB2CWrxUGumY2eAgbTTOY3HW3lrIuou4T+wPPAdnH1NiwFcCfVM4DcI2ZTN PvLMjVheIkU+hB3Rm1WXGRR0wAD7dd6/Is6eiIW6AfgrgkyTkx45Yo0e6JlB/+rgI3A9 Ye+wgETRfXf5dDOEv7DHF3JcXiOqlv+iuMiTp058SHGz2cAAWKl5Y2Huco9lXwSBdVKA +azA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=tEdIw9wvH2zzikieh/eX5e+Rn+l7enMUtCDEVtvQdrk=; b=DPCqNSFENrNaZKywUqEHcoF7+vUDuii209op9Jhw4yI/TV/6XUbLuQf+7WtaRNvHYI uzOVnNMBqEI3EQqvb9cRY9c/xkSPzCkOFraULBzDkTRNp8yrAOZ9z7obbpN/CPgHjFig LDebmSQDOrbg5Ge4dkqPX5+9JEWYpqJ9KVYpXAyLFsgNrnMKuBnkYVzbpdWgoqbm56sk YmN8PVY7jF3ZfsOlAoIjUwZTHoCwpXGXPNxcyBpf69zUMpK0hxdCwUodG9J1LNEE+GA+ zWvFFAX6HwdsdV2LkK1VcwDeu/MgaZRJgu/NLJoouLve35qKc81TDFWU3E5UM0ADaEG3 j8eA== X-Gm-Message-State: AOAM532cl9SiWACHU/ZQEo+PYH2gBertlmk9wcAoPN9yHxcB+aCWTiiV U1wseTVPMY8WStpVyCRQfow= X-Google-Smtp-Source: ABdhPJw2RbNlH1CI/XMN31AVt5cBqVHbtguMFCuLTIRR3y0VtDDhtWko0pU27pPdEeTzVhMuLYIUcQ== X-Received: by 2002:a05:6512:1054:: with SMTP id c20mr3147735lfb.654.1643298857761; Thu, 27 Jan 2022 07:54:17 -0800 (PST) Received: from pc638.lan ([155.137.26.201]) by smtp.gmail.com with ESMTPSA id m22sm1689600lfq.192.2022.01.27.07.54.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jan 2022 07:54:17 -0800 (PST) From: Uladzislau Rezki X-Google-Original-From: Uladzislau Rezki Date: Thu, 27 Jan 2022 16:54:15 +0100 To: Michal Hocko , Andrew Morton Cc: Manfred Spraul , Andrew Morton , LKML , Vasily Averin , cgel.zte@gmail.com, shakeelb@google.com, rdunlap@infradead.org, dbueso@suse.de, unixbhaskar@gmail.com, chi.minghao@zte.com.cn, arnd@arndb.de, Zeal Robot , linux-mm@kvack.org, 1vier1@web.de, stable@vger.kernel.org Subject: Re: [PATCH] mm/util.c: Make kvfree() safe for calling while holding spinlocks Message-ID: References: <20211222194828.15320-1-manfred@colorfullife.com> <20220126185340.58f88e8e1b153b6650c83270@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: nil X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: AE49320011 X-Stat-Signature: kxkjgxhuonk31qtazi815px5tkfe4iba Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=RFckaGUn; spf=pass (imf13.hostedemail.com: domain of urezki@gmail.com designates 209.85.167.43 as permitted sender) smtp.mailfrom=urezki@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1643298859-422254 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 Thu, Jan 27, 2022 at 09:25:48AM +0100, Michal Hocko wrote: > On Thu 27-01-22 06:59:50, Manfred Spraul wrote: > > Hi Andrew, > > > > On 1/27/22 03:53, Andrew Morton wrote: > > > On Wed, 22 Dec 2021 20:48:28 +0100 Manfred Spraul wrote: > > > > > > > One codepath in find_alloc_undo() calls kvfree() while holding a spinlock. > > > > Since vfree() can sleep this is a bug. > > > > > > > > Previously, the code path used kfree(), and kfree() is safe to be called > > > > while holding a spinlock. > > > > > > > > Minghao proposed to fix this by updating find_alloc_undo(). > > > > > > > > Alternate proposal to fix this: Instead of changing find_alloc_undo(), > > > > change kvfree() so that the same rules as for kfree() apply: > > > > Having different rules for kfree() and kvfree() just asks for bugs. > > > > > > > > Disadvantage: Releasing vmalloc'ed memory will be delayed a bit. > > > I know we've been around this loop a bunch of times and deferring was > > > considered. But I forget the conclusion. IIRC, mhocko was involved? > > > > I do not remember a mail from mhocko. > > I do not remember either. > > > > > Shakeel proposed to use the approach from Chi. > > > > Decision: https://marc.info/?l=linux-kernel&m=164132032717757&w=2 > > And I would agree with Shakeel and go with the original change to the > ipc code. That is trivial and without any other side effects like this > one. I bet nobody has evaluated what the undconditional deferred freeing > has. At least changelog doesn't really dive into that more than a very > vague statement that this will happen. > Absolutely agree here. Especially that changing the kvfree() will not look stable. After applying the https://www.spinics.net/lists/linux-mm/msg282264.html we will be able to use vfree() from atomic anyway. -- Vlad Rezki