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=-7.0 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS 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 CFE89C34026 for ; Tue, 18 Feb 2020 11:31:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7598121D56 for ; Tue, 18 Feb 2020 11:31:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7598121D56 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CF1D06B0003; Tue, 18 Feb 2020 06:31:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CA2A86B0006; Tue, 18 Feb 2020 06:31:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B91B56B0007; Tue, 18 Feb 2020 06:31:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0129.hostedemail.com [216.40.44.129]) by kanga.kvack.org (Postfix) with ESMTP id A186C6B0003 for ; Tue, 18 Feb 2020 06:31:06 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 5669E4404 for ; Tue, 18 Feb 2020 11:31:06 +0000 (UTC) X-FDA: 76503031332.23.moon99_43cde757c9c2f X-HE-Tag: moon99_43cde757c9c2f X-Filterd-Recvd-Size: 4582 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by imf15.hostedemail.com (Postfix) with ESMTP for ; Tue, 18 Feb 2020 11:31:05 +0000 (UTC) Received: by mail-wr1-f68.google.com with SMTP id t3so23474444wru.7 for ; Tue, 18 Feb 2020 03:31:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ZnoR/TIx7fKj96R5zmBvT3nyCVKnUxPHKYaYVRB0FaU=; b=CfBl55Tcm7zH9CH+mPvPTSaKQVQnemjkEWlLWDD/T7hXKKUaTIz1buTEfQR0I5HrUu 8cotUa+srjtCmtuI+y+fWIAF6BxQnx8F4Xi2noBS/6CEqfChc6E3ZuEhCavq6TEMnOE/ O51dKpm9KwxF/F6EX3dJ9VOxIC7h+Ho/q59h4z6Dv6StElVs9ePk01TXEAKG9fM6GFNV eIaiF/mdvPQqRzTNGVCqj/nezI9r69zdpPoiu93OHUe8yDOb5OOpBPzGZr6NukmABiMT BAlWMIBjlwxbbpybt3alSvSblYM/FYXEsKoJE2Rl0GwmugBdtEahkv+DO6Wqb2A9PSD3 e4OQ== X-Gm-Message-State: APjAAAXswKIHHDYO97lo34NVM8oN8tEe3+Ef9HBL/scPe4Xq2uVi/oS3 gS+gtGjF5ZajeI4zXDJ0U5M= X-Google-Smtp-Source: APXvYqx87NFgrpW3Y1vBrUUCZftoRQVXXG7WEdLVovV2FtSe62x/EMmLQIe+n9wpkKP19tQQdaXYkA== X-Received: by 2002:adf:f401:: with SMTP id g1mr27996186wro.129.1582025464604; Tue, 18 Feb 2020 03:31:04 -0800 (PST) Received: from localhost (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id b18sm5697555wru.50.2020.02.18.03.31.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Feb 2020 03:31:03 -0800 (PST) Date: Tue, 18 Feb 2020 12:31:03 +0100 From: Michal Hocko To: Andrea Arcangeli Cc: Will Deacon , Catalin Marinas , Jon Masters , Rafael Aquini , Mark Salter , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 1/2] mm: use_mm: fix for arches checking mm_users to optimize TLB flushes Message-ID: <20200218113103.GB4151@dhcp22.suse.cz> References: <20200203201745.29986-1-aarcange@redhat.com> <20200203201745.29986-2-aarcange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200203201745.29986-2-aarcange@redhat.com> 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 03-02-20 15:17:44, Andrea Arcangeli wrote: > alpha, ia64, mips, powerpc, sh, sparc are relying on a check on > mm->mm_users to know if they can skip some remote TLB flushes for > single threaded processes. > > Most callers of use_mm() tend to invoke mmget_not_zero() or > get_task_mm() before use_mm() to ensure the mm will remain alive in > between use_mm() and unuse_mm(). > > Some callers however don't increase mm_users and they instead rely on > serialization in __mmput() to ensure the mm will remain alive in > between use_mm() and unuse_mm(). Not increasing mm_users during > use_mm() is however unsafe for aforementioned arch TLB flushes > optimizations. So either mmget()/mmput() should be added to the > problematic callers of use_mm()/unuse_mm() or we can embed them in > use_mm()/unuse_mm() which is more robust. I would prefer we do not do that because then the real owner of the mm cannot really tear down the address space and the life time of it is bound to a kernel thread doing the use_mm. This is undesirable I would really prefer if the existing few users would use mmget only when they really need to access mm. > Signed-off-by: Andrea Arcangeli > --- > mm/mmu_context.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/mm/mmu_context.c b/mm/mmu_context.c > index 3e612ae748e9..ced0e1218c0f 100644 > --- a/mm/mmu_context.c > +++ b/mm/mmu_context.c > @@ -30,6 +30,7 @@ void use_mm(struct mm_struct *mm) > mmgrab(mm); > tsk->active_mm = mm; > } > + mmget(mm); > tsk->mm = mm; > switch_mm(active_mm, mm, tsk); > task_unlock(tsk); > @@ -57,6 +58,7 @@ void unuse_mm(struct mm_struct *mm) > task_lock(tsk); > sync_mm_rss(mm); > tsk->mm = NULL; > + mmput(mm); > /* active_mm is still 'mm' */ > enter_lazy_tlb(mm, tsk); > task_unlock(tsk); > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel -- Michal Hocko SUSE Labs