Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1223191ybf; Sun, 1 Mar 2020 04:07:52 -0800 (PST) X-Google-Smtp-Source: APXvYqzs3q8CzeNUaFAGVpSCxaG9Wp23I9CEVtG93Kmkns8WItH1nRT8PKEJ5V1CG5qlzq8GxJWv X-Received: by 2002:a05:6830:19:: with SMTP id c25mr3762614otp.349.1583064472405; Sun, 01 Mar 2020 04:07:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583064472; cv=none; d=google.com; s=arc-20160816; b=0JbG8jTD+PzELPeqahS05w1OTkBYy1nRs03wBhDM2ookKxLRFaSjwGogPd2wY2rooH Tzb92sMK9YQo2Q/4xl+2ComA+cztiBLmXE4mWB16i64Ry1p2tAMVFh/KwoV/df8C3ygi FkZ18s1OOXm7dgKtJpgE0aC7iXQxp31wGDq5K/aEcdU6KJnROqQ+/jydXgY1ikjPRqkt KgdOuoIBH539fWSbxI4ILL8uI8Lba5BqB6hPpapB0XxMy071t1Ui6SeE9Ue6ZwVK/Wup 1gbrWqyd6qk+h2HLVGnAsgSFoaWFLTXO+VJs2ydE0E28i7/kFUiXuyNCtBN9vFXLMfwY 0z2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:date:from:dkim-signature; bh=g2L1+KgmlL2UuREJ51pRnap9NUM12a+0vrG5ju6s47k=; b=tfAm/PQteTZopmbErsZ+vYo22vxWDtB0/J0j55XZdyBKrzYeBJLHZ1OuDAGnfQtWWk tFND2avZI0J/OXx8sYdI9LgxJS/erhaXP3mtRgfQovIpm3l+frrz7vIm6jXYtaWwiSOk WkGSnsP/Qso5r6JYAq2b11ptyfwutNqu+p6gOqI+Ruo8N5W7bSUhnbB2ny+84GBCnHCW Mn34B3xp0IPuh6Lu/d2ZumcmSIYIGqU4tqeL4tvYQA0sitkhJZP4vJ1ipp8Xcj4e4BZs R0Db5CsIinQ/IUxmKgkIAVMdW/IBaE7lLgsimpseyZpGjE44RFaki0Ur/n8PnaN2Gn6n qvMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cm++Sacg; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z3si4276895oib.164.2020.03.01.04.07.15; Sun, 01 Mar 2020 04:07:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cm++Sacg; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725887AbgCAMHO (ORCPT + 99 others); Sun, 1 Mar 2020 07:07:14 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:37906 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725877AbgCAMHO (ORCPT ); Sun, 1 Mar 2020 07:07:14 -0500 Received: by mail-wm1-f65.google.com with SMTP id u9so2144299wml.3; Sun, 01 Mar 2020 04:07:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=g2L1+KgmlL2UuREJ51pRnap9NUM12a+0vrG5ju6s47k=; b=cm++SacgY/WsKGaPbcOuT0Uwowg2582zZnNETSWcg7edGvMYVSSMxWSHsyWIHFhGge EsjQHldCUqk8Csufplp/EdsNhunbc782WqkC2xOvj556FWgINUyipxApg6A4RwkcDrVk pfsxvvw6TCDDM9O4gw/ARz71Vm+0QLYI6lFLQxHfJ4KEfyJU1fn07pr5L7wOxgidcPlJ VGKed0Luc1UifI0XW+2kPGClgdke6ZMePUCgpREl7hoXXbZGDI2zt8uEy9kltORrzi6S NypIzMkLgdTe+7dJvrvgxAFbeig7XYsHVmvW7MgQ2KcUsLwTlFBVxuZxVjJIvN6CUe1y /6dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=g2L1+KgmlL2UuREJ51pRnap9NUM12a+0vrG5ju6s47k=; b=jyelyGe1ZIdf4KmiooVlQ2rbKM/IMCM/AXBtJLAVn8FmZWuSmO5HblCyPNQPDDV/JG 6dAqMDyuZDWB1htgJ/sy9akq0IMSmJloSjcvQJKq/Vt28tjj9pzUY9cNpHAI98ePCpEE iSjNUixbuE2kJbUvJMoJF6OCvU9pcjZ1+Za8QUgdgBy0PdzQQj+qESC87Rfr+F2TShUc a+DKaDjo7ptDrB7SNSmWhXqbvzZ3ARALDUb5FPt6h3iyi9tvIe/6gsSLaqM39rPBuj6w qTaP3+KU6o5Qt35rjdqWKmNcgdIY1/LyyWOFALLiigTLX92xFJqKwe0toaB7y2f80zYV J1gQ== X-Gm-Message-State: APjAAAVv/ZK+jAJlzC7SaK4YhrluQvMDVWNdbMI0VJghQPEDAM00D5VR DamDQHJDgPbEUsxPw3OlFis= X-Received: by 2002:a05:600c:149:: with SMTP id w9mr13676684wmm.132.1583064432518; Sun, 01 Mar 2020 04:07:12 -0800 (PST) Received: from pc636 ([80.122.78.78]) by smtp.gmail.com with ESMTPSA id x8sm9727390wro.55.2020.03.01.04.07.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Mar 2020 04:07:11 -0800 (PST) From: Uladzislau Rezki X-Google-Original-From: Uladzislau Rezki Date: Sun, 1 Mar 2020 13:07:02 +0100 To: Joel Fernandes Cc: Joel Fernandes , "Paul E. McKenney" , "Theodore Y. Ts'o" , Ext4 Developers List , Suraj Jitindar Singh , LKML Subject: Re: [PATCH RFC] ext4: fix potential race between online resizing and write operations Message-ID: <20200301120702.GA9762@pc636> References: <20200221003035.GC2935@paulmck-ThinkPad-P72> <20200221131455.GA4904@pc636> <20200221202250.GK2935@paulmck-ThinkPad-P72> <20200222222415.GC191380@google.com> <20200223011018.GB2935@paulmck-ThinkPad-P72> <20200224174030.GA22138@pc636> <20200225020705.GA253171@google.com> <20200225185400.GA27919@pc636> <20200227133700.GC161459@google.com> <20200301110843.GA8725@pc636> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200301110843.GA8725@pc636> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org > > > So in CONFIG_PREEMPT kernel we can identify if we are in atomic or not by > > > using rcu_preempt_depth() and in_atomic(). When it comes to !CONFIG_PREEMPT > > > then we skip it and consider as atomic. Something like: > > > > > > > > > static bool is_current_in_atomic() > > > > Would be good to change this to is_current_in_rcu_reader() since > > rcu_preempt_depth() does not imply atomicity. > > > can_current_synchronize_rcu()? If can we just call: > > > synchronize_rcu() or synchronize_rcu_expedited(); > kvfree(); > > > > > { > > > #ifdef CONFIG_PREEMPT_RCU > > > if (!rcu_preempt_depth() && !in_atomic()) > > > return false; > > > > I think use if (!rcu_preempt_depth() && preemptible()) here. > > > > preemptible() checks for IRQ disabled section as well. > > > Yes but in_atomic() does it as well, it also checks other atomic > contexts like softirq handlers and NMI ones. So calling there > synchronize_rcu() is not allowed. > Ahh. Right you are. We also have to check if irqs are disabled or not. preemptible() has to be added as well. can_current_synchronize_rcu() { if (IS_ENABLED(CONFIG_PREEMPT_RCU)) { if (!rcu_preempt_depth() && !in_atomic() && preemptible()) { might_sleep(); return true; } } return false; } if we can synchronize: - we can directly inline kvfree() to current context; - we can attached the head using GFP_KERNEL | __GFP_RETRY_MAYFAIL. Otherwise attached the rcu_head under atomic or as we are in RCU reader section. Thoughts? -- Vlad Rezki