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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3DE60C38142 for ; Mon, 23 Jan 2023 17:08:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qFpEtMt8RVA/ZCsLMVdvl9XyT8OVyQWwy12IVd9MLfk=; b=ZOiDh6j55Q1FjA gpm2Ipx+ka44Mbwca3dIJXSy6mNhuknN4MKw+7h+8L+lFRAz4itojnTyAP3IRdzeSsa1tu9vkcOu6 /LJAZT7LuX+zNdT/p9pOUNOrAzakdFn8USUb46/Bo1XTq8LlpNShjy/88wWb2T7HKyAImn7PHW5od 2QPb2VCNunGdqOl9WcTcXc1JZHvSB88p66eNPSycL0K1IPIGJ1hKLSMwUiCv/IW7LucAqpOdXLYv/ 9x55i17qlLUPpv9nacgVuBCiVRrf+3qeDn4BhPQN2kQnA6gdhVFjGukq5UPIT2tI2lGNrv+K9HKWb jv7FlYKCcIzRwFQgRSkA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pK0IU-000m3u-C5; Mon, 23 Jan 2023 17:07:54 +0000 Received: from mail-yb1-xb33.google.com ([2607:f8b0:4864:20::b33]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pK0IQ-000m2h-8D for linux-arm-kernel@lists.infradead.org; Mon, 23 Jan 2023 17:07:51 +0000 Received: by mail-yb1-xb33.google.com with SMTP id p15so12038302ybu.7 for ; Mon, 23 Jan 2023 09:07:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=0FW2Lu3pQY4jZR84HYv4JQ4VKgnKPsvFkN66d0OQdfk=; b=Rdkh5YvSKKbAMeVrmVNplinHHWb9L0j8rdsuQhapYgNXgo2gD8OT9rPe2ZaYeKAx5E pquLD54vscJdCDSHhWXmL1EWzDt5pyAG1htz3dnPZFHMU65k7/ecAz8h560ev1Whkpkx GmJi3/qAY1SytqJGcHyL7ZauQwcXJIeewko/PfLsfneDZVVLvC6oLIKSy4xP3e27K+yS i+du5yv0dwEDCaLuKuAjKsXUTksGEyuqnkOl0M4LdMY5aXamVLJ2M8zCnWuE09jvAmuF sB/MZ98fMFzyGzj/8ucdRz1+7hR1rvsj7rFOBbeWzzRB8MHHZmcx/qo6hKDyOuhNc/f8 Lcuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0FW2Lu3pQY4jZR84HYv4JQ4VKgnKPsvFkN66d0OQdfk=; b=SgGPnTjnSIBf0vLYukTUBx82EG7HsD1DIwmbw/ce/xyWrkP6fFXzdXEQBN18d2po3e Gblt3HQvn1FgE6WhNPgSptIZho96RbMmqQMOorRb6L+OQ+3AXtbhWhhYk8/ik321CdqE eVkDN3lZkjagSroSp/mCuZkNWZxqPsN0e0SsVr//ZQylOnAtGvM/MCCde/fiI8czG/ol t41N5CqCZzaUnc+CBRjQ0oq6sh/x3QckWa8xu6oKV6WfdVMpl+2DS9lhC1B16yIL14so C3jTdcqrHB/LQjiWlBV0WD29+kKGQ23E0DlSj+dLR2ZalhvO8evZfgZ+0BoX6R/+BMgQ D3wg== X-Gm-Message-State: AFqh2koUYSRRGciN3sBKWUJgDvzpROBkOOKPf0XyJc2IoFUGN0jqDUK5 5XC/ZpatEFExCZDKAvvke7x5J75/09ScmvWZHBOF9Q== X-Google-Smtp-Source: AMrXdXuiJMyjRQftHqmMyvImwNLCOEQZDFoh5cTDm5Yhcc0MUbhCxbDK85e3u9MmqqS9nUopxnOnX6EdJLA1Sjcj6S4= X-Received: by 2002:a25:ceca:0:b0:7e4:115c:9cf6 with SMTP id x193-20020a25ceca000000b007e4115c9cf6mr2777687ybe.316.1674493667105; Mon, 23 Jan 2023 09:07:47 -0800 (PST) MIME-Version: 1.0 References: <20230120170815.yuylbs27r6xcjpq5@revolver> In-Reply-To: From: Suren Baghdasaryan Date: Mon, 23 Jan 2023 09:07:34 -0800 Message-ID: Subject: Re: [PATCH 39/41] kernel/fork: throttle call_rcu() calls in vm_area_free To: Michal Hocko Cc: Matthew Wilcox , "Liam R. Howlett" , akpm@linux-foundation.org, michel@lespinasse.org, jglisse@google.com, vbabka@suse.cz, hannes@cmpxchg.org, mgorman@techsingularity.net, dave@stgolabs.net, peterz@infradead.org, ldufour@linux.ibm.com, laurent.dufour@fr.ibm.com, paulmck@kernel.org, luto@kernel.org, songliubraving@fb.com, peterx@redhat.com, david@redhat.com, dhowells@redhat.com, hughd@google.com, bigeasy@linutronix.de, kent.overstreet@linux.dev, punit.agrawal@bytedance.com, lstoakes@gmail.com, peterjung1337@gmail.com, rientjes@google.com, axelrasmussen@google.com, joelaf@google.com, minchan@google.com, jannh@google.com, shakeelb@google.com, tatashin@google.com, edumazet@google.com, gthelen@google.com, gurua@google.com, arjunroy@google.com, soheil@google.com, hughlynch@google.com, leewalsh@google.com, posk@google.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-kernel@vger.kernel.org, kernel-team@android.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230123_090750_331088_B43A0288 X-CRM114-Status: GOOD ( 28.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Jan 23, 2023 at 8:55 AM Michal Hocko wrote: > > On Mon 23-01-23 08:22:53, Suren Baghdasaryan wrote: > > On Mon, Jan 23, 2023 at 1:56 AM Michal Hocko wrote: > > > > > > On Fri 20-01-23 09:50:01, Suren Baghdasaryan wrote: > > > > On Fri, Jan 20, 2023 at 9:32 AM Matthew Wilcox wrote: > > > [...] > > > > > The page fault handler (or whatever other reader -- ptrace, proc, etc) > > > > > should have a refcount on the mm_struct, so we can't be in this path > > > > > trying to free VMAs. Right? > > > > > > > > Hmm. That sounds right. I checked process_mrelease() as well, which > > > > operated on mm with only mmgrab()+mmap_read_lock() but it only unmaps > > > > VMAs without freeing them, so we are still good. Michal, do you agree > > > > this is ok? > > > > > > Don't we need RCU procetions for the vma life time assurance? Jann has > > > already shown how rwsem is not safe wrt to unlock and free without RCU. > > > > Jann's case requires a thread freeing the VMA to be blocked on vma > > write lock waiting for the vma real lock to be released by a page > > fault handler. However exit_mmap() means mm->mm_users==0, which in > > turn suggests that there are no racing page fault handlers and no new > > page fault handlers will appear. Is that a correct assumption? If so, > > then races with page fault handlers can't happen while in exit_mmap(). > > Any other path (other than page fault handlers), accesses vma->lock > > under protection of mmap_lock (for read or write, does not matter). > > One exception is when we operate on an isolated VMA, then we don't > > need mmap_lock protection, but exit_mmap() does not deal with isolated > > VMAs, so out of scope here. exit_mmap() frees vm_area_structs under > > protection of mmap_lock in write mode, so races with anything other > > than page fault handler should be safe as they are today. > > I do not see you talking about #PF (RCU + vma read lock protected) with > munmap. It is my understanding that the latter will synchronize over per > vma lock (along with mmap_lock exclusive locking). But then we are back > to the lifetime guarantees, or do I miss anything. munmap() or any VMA-freeing operation other than exit_mmap() will free using call_rcu(), as implemented today. The suggestion is to free VMAs directly, without RCU grace period only when done from exit_mmap(). That' because VMA freeing flood has been seen so far only in the case of exit_mmap() and we assume other cases are not that heavy to cause call_rcu() flood to cause regressions. That assumption might prove false but we can deal with that once we know it needs fixing. > -- > Michal Hocko > SUSE Labs _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel