Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp887051pxf; Thu, 11 Mar 2021 18:18:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJwfKisYlkzVe4I/61Qm9Q9BDnwRkT8T8AUBvSMnppuBwUrcktLxutSy9IQm/GALSbUOmpry X-Received: by 2002:a50:f113:: with SMTP id w19mr11420309edl.226.1615515526847; Thu, 11 Mar 2021 18:18:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615515526; cv=none; d=google.com; s=arc-20160816; b=UzjfKov6tNz+1ls5S6oYaH2KnShPo9WOaKdp0jvp3UMuThAeLocYaWz153s3sFjwdA ZJ1L+VjrIB3/0FSOdQahSpvmFshsXfJGk42X8JD1LAU0D+LlfpLl9KYinBn5bFiBIIb+ rMCEaifIsdP/pyXxIuIzcGPYqgxNuMGoQaVoIXInixvEY4GLLN2+SQgwjI28072IbJUt 7hqxoxdqRzxuT+Se7+u59wxvu2LTmNTMpu3IlmDt7tgRmog5ettGP9aWwQMZhz7TYUnZ 47iHjiwTcgaRAEywH7jM99nxTgicf6XZwvvseZWIFpLOpfhNJRJTKSV8PmUsjPEs4miX +VAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:sender:dkim-signature; bh=DLypqHmd9Wl8adDWo2RyhZBE8XSLiDUVzOC9qvznIU8=; b=C/0sk0Zgjt88WrVKSUhvUIsSBNR6RIj4E0BzknQ3+1hEOusjjwzrj9ql4vt1a+wUTj zFI+HkQE63oNFcF4zIHoZIT6bx2BtGZZ8gSnSg3lB5J4k7F9w4CLd4TcrRKo3vL4IAkj TcZnE65TYKYZIWjkicYEtyliz8LHXMGpm8dtAHl+dGul/dCKlC4bdmv5snBqc19SEfVw UY3Yt3biqmrXgGTSmdkjOgXK26sCLEnmyQN38VJSl44sVgsGoa8dC4isAU6FBtDVLMrp F4wc4Spc1mLw4bksMUg/Pozxd0oBGGM790erOwVUwoiAW14VFyn594RFuAQGeHKcM9eW zLcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=B3oWOI+K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a1si2868326ejt.680.2021.03.11.18.18.23; Thu, 11 Mar 2021 18:18:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=B3oWOI+K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229568AbhCLCPP (ORCPT + 99 others); Thu, 11 Mar 2021 21:15:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229558AbhCLCOo (ORCPT ); Thu, 11 Mar 2021 21:14:44 -0500 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74892C061574; Thu, 11 Mar 2021 18:14:44 -0800 (PST) Received: by mail-pf1-x42d.google.com with SMTP id a188so834368pfb.4; Thu, 11 Mar 2021 18:14:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=DLypqHmd9Wl8adDWo2RyhZBE8XSLiDUVzOC9qvznIU8=; b=B3oWOI+K2T5zV/Md7TadfLAmGLPu+uD1roU9mISoVp8QM6Lton5aFPivU8QWfVxj4j 5zfvtkNN2yjCDsDAt27yTASwV8QOfEq5cT58TNhxWU0dL/g/6DYGP47z6dSqzhPsI2I+ BDc9thgGofUPaS4GbYAqm6nR0VgRjU7LiWtACxjR0TddbJFDRvZXvIVbt1JCUrcL0bhe 8F1E+XSbMT5jQZ1E331ImgIUYr7nQe4+a78GtAqAUe8O9PKjDC/eOiAIhkd0btitmR98 BQmrgY3a74lrgjv3kSNGf+FLhv9Sl7ncAUKrwi2BgvO8kuspQm3smpflI/pZ6a2MHJ+9 xj9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=DLypqHmd9Wl8adDWo2RyhZBE8XSLiDUVzOC9qvznIU8=; b=YKapaVX+tC4G7bELxBX9uIeYbJAwfaMB+0DA1Vh+PqDPEch0roKT18qX5uiAlFptwN 7kKqNqxOO+WiI1pnhy/zAS2yO0UgSzI97fj29CXG4rOb+jD/UVqnvkAEE8YgBHdAxL+S j8D9TXj7LYCZizYjIUgFMKuvHe3IZPUnhnskn/Ii4vSlTDWO9blZYIj0xtZyBsmCQ26o RwzM7l2VX5Y4uIleCQgZoNZR9ibBZW+E1FIg72/eVI/v5nOnA1e+HALo9UXTpQcI4lyb 7LLckPfATZK1aHm8P1H0GrBU6Qqd3KgfKSKY97tATlqi9zPji5z4HPsSBpudGzbc9dd/ 8hCw== X-Gm-Message-State: AOAM531YAWFWKtyhptMqqHC/UQC+l66bSvl42C6MTQhQAdehqe/+IfyO dJxGJ0jf2nWYzxsAmdam8uU= X-Received: by 2002:a63:fb18:: with SMTP id o24mr9404191pgh.55.1615515283833; Thu, 11 Mar 2021 18:14:43 -0800 (PST) Received: from google.com ([2620:15c:211:201:64cb:74c7:f2c:e5e0]) by smtp.gmail.com with ESMTPSA id l22sm371771pjl.14.2021.03.11.18.14.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Mar 2021 18:14:42 -0800 (PST) Sender: Minchan Kim Date: Thu, 11 Mar 2021 18:14:40 -0800 From: Minchan Kim To: Luis Chamberlain , gregkh@linuxfoundation.org Cc: ngupta@vflare.org, sergey.senozhatsky.work@gmail.com, axboe@kernel.dk, mbenes@suse.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] zram: fix crashes due to use of cpu hotplug multistate Message-ID: References: <20210306022035.11266-1-mcgrof@kernel.org> <20210306022035.11266-2-mcgrof@kernel.org> <20210310212128.GR4332@42.do-not-panic.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210310212128.GR4332@42.do-not-panic.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 10, 2021 at 09:21:28PM +0000, Luis Chamberlain wrote: > On Mon, Mar 08, 2021 at 06:55:30PM -0800, Minchan Kim wrote: > > If I understand correctly, bugs you found were related to module > > unloading race while the zram are still working. > > No, that is a simplifcation of the issue. The issue consists of > two separate issues: > > a) race against module unloading in light of incorrect racty use of > cpu hotplug multistate support Could you add some pusedo code sequence to show the race cleary? It would be great if it goes in the description, too since it's more clear to show the problme. > b) module unload race with sysfs attribute race on *any* driver which > has sysfs attributes which also shares the same lock as used during > module unload Yub, that part I missed. Maybe, we need some wrapper to zram sysfs to get try_module_get in the warapper funnction and then call sub rountine only if it got the refcount. zram_sysfs_wrapper(func, A, B) if (!try_module_get(THIS_MODULE) return -ENODEV; ret = func(A,B); module_put(THIS_MODULE); return ret; > > It is important to realize that issue b) is actually a generic kernel > issue, it would be present on *any* driver which shares a lock used on > a sysfs attribute and module unload. I looked to implement a generic > solution on kernfs, however we don't yet have semantics to enable this > generically, and so for now each driver needs to deal with those races > on their own. That sysfs race is dealt with in the second patch. It's unforunate. Let me Cc Greg who might have some ideas or find zram mess on zram sysfs implementation. > > The first patch only deals with the cpu hotplug races exposed at module > unloading. True. Thanks for the clarification.