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=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,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 E7820C3F2CD for ; Tue, 3 Mar 2020 04:28:30 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id B5BFC20716 for ; Tue, 3 Mar 2020 04:28:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ZJjW70AN"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WsZixNvW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B5BFC20716 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fr8wc+DDsO21YFlChVzIgrqAQNklmBF5BQ+xWzL+OQk=; b=ZJjW70ANqVAsCE yrsThJXlP04HJJRPK4p/p2ejZmF77C53fansvt4nROzB1xOLOksh1IgRYCoCmBxxp/Ll1k5AA18hM 0ziltEyydy6lNsuN6kltKBny06XUSqi7W3TrxClTa3AByatODNRtHgilphSQ7gzXZMSNycVY+hLp1 7KjnhBQ5CFWUldCuhnDvcbNPhvA2bAuTzEuIKO6GOdCPAGFapTxwKTwZekz1ZQ41GrQzgEkO+5t5B 1yhmJc0JjqPpUiIPs5eKBxe53jOkmvfg2mGO5TAzhu7l8e9PPOVtLZEPfwWGqBOjxZnnJDn79rRYH 2ONyvmF0RkXPhNsubI0Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j8zAJ-0001vs-IE; Tue, 03 Mar 2020 04:28:19 +0000 Received: from us-smtp-2.mimecast.com ([207.211.31.81] helo=us-smtp-delivery-1.mimecast.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j8zAG-0001uh-8Y for linux-arm-kernel@lists.infradead.org; Tue, 03 Mar 2020 04:28:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583209693; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=GDMIPd7v29HF3qLCK2yjuGYjUXKITzcTwLkju8pHxl0=; b=WsZixNvWQsrgG7G/9vOGXdWXeIqXuasGYdIJCu/S9qeaueLi22yfHCiBNGawRQCCp52aSt KOp4L6ytwhg/Pazi/Duh8hgTW5KunfMrknfsFvW81Yvl58kyQasTxPic91u0tSnCoAjowu l/I8LXNbwOiqepjt8v1L55P3suWg3wM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-185-BfzygFwcMtmV8FItHabr5g-1; Mon, 02 Mar 2020 23:28:09 -0500 X-MC-Unique: BfzygFwcMtmV8FItHabr5g-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 317098017CC; Tue, 3 Mar 2020 04:28:08 +0000 (UTC) Received: from t490s (ovpn-116-88.phx2.redhat.com [10.3.116.88]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A9CB68D568; Tue, 3 Mar 2020 04:28:06 +0000 (UTC) Date: Mon, 2 Mar 2020 23:28:04 -0500 From: Rafael Aquini To: Andrea Arcangeli Subject: Re: [PATCH 1/3] mm: use_mm: fix for arches checking mm_users to optimize TLB flushes Message-ID: <20200303042804.GA94763@t490s> References: <20200223192520.20808-1-aarcange@redhat.com> <20200223192520.20808-2-aarcange@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200223192520.20808-2-aarcange@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200302_202816_381759_C9E9284A X-CRM114-Status: GOOD ( 16.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: QI Fuli , Jon Masters , Catalin Marinas , linux-kernel@vger.kernel.org, Michal Hocko , linux-mm@kvack.org, Mark Salter , Will Deacon , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sun, Feb 23, 2020 at 02:25:18PM -0500, 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. > > 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); Acked-by: Rafael Aquini _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel