Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1956717ybz; Thu, 30 Apr 2020 08:22:26 -0700 (PDT) X-Google-Smtp-Source: APiQypI8H7p03yMj9kiysYxtZY1ipv7IHgxZTEwXjMBapAbjEIhwxgi5svJDVHoI51UvI5XtL3lc X-Received: by 2002:aa7:db0b:: with SMTP id t11mr3004095eds.304.1588260146207; Thu, 30 Apr 2020 08:22:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588260146; cv=none; d=google.com; s=arc-20160816; b=g37mzKrnzGXxsp0T5usF+0XDA5uwGI9rnChzg9sWumc4z9sFHKbOhX1D1ga37IDLQx 8toBzCUi63K9RK+5Qx7SKmD4HbpZqpE/VcOqP/J2IyDJ3pIcGOhYiICsalhptpUQakcH zqREE2Lfqj3ft3uVziXpFOBwmMlyOUQ+wf4t4s3XHsH6qZrrZUHEMWvg3mKDxmFdsWSZ UfYCFYHbcZNqA4gKoQ//PQaQpeOtUgkuWGSF9JwhNvp1eQIwPOmH13mPnnT1IECC5nQM +0Rad5l5+5xg1TIt9xPNZPvzVSe3q3/G9VJkpBW9Dox83V4DH8jfutnyiqAv/fjNflHT OE6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:dkim-signature:dkim-filter; bh=Lu6W5976+YDF4QPySU4/Jni56pOvaynH+19pRZWdrr4=; b=VvFA95RyaP7KwdXh6/MrT2AWpMa21ztFoekBC91k8y5iI/pCb8caAhqpbZ5L3yfZ7S n0ttIjRTV8NsThz2z7IV/aMrIMrl1iyPm70DIwDoJsFVKXqnsNPbN5F3tfZ0HfrZ8Heu g2eu34Vgzs9PiWvofC/bZIaVCqtU9DSV3bBptLZqMCZUwDcYoWwyIbYTzgMapXSdErI3 RQCo7DEuKpMNMvJ9E0eHsPrXAy6tbisJh2yAm93hl13Y2pC8rXNnfreyagwYYROE14IH Aq4qivhs91Dq+i0vMNods5zrwcop0fPitTxiftmJjy50ViFvAD2BzJCLHs2pbXSe83jc pl5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=ovhxWUTI; 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=efficios.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d1si5660064edj.453.2020.04.30.08.22.00; Thu, 30 Apr 2020 08:22:26 -0700 (PDT) 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=@efficios.com header.s=default header.b=ovhxWUTI; 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=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726736AbgD3PUR (ORCPT + 99 others); Thu, 30 Apr 2020 11:20:17 -0400 Received: from mail.efficios.com ([167.114.26.124]:51162 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726468AbgD3PUR (ORCPT ); Thu, 30 Apr 2020 11:20:17 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id F36F528F2D9; Thu, 30 Apr 2020 11:20:15 -0400 (EDT) Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id qNbj4V80Mxgb; Thu, 30 Apr 2020 11:20:15 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 9BC7B28F4C5; Thu, 30 Apr 2020 11:20:15 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 9BC7B28F4C5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1588260015; bh=Lu6W5976+YDF4QPySU4/Jni56pOvaynH+19pRZWdrr4=; h=Date:From:To:Message-ID:MIME-Version; b=ovhxWUTIpdBc84kPQiTlr4mY6vQEJfAFOBmlZUryLQE5eHcIvkgxBr+w9HLGOFzME Z3VVGGBEfLbjPsD9K2dZZclCcWhlC8ubVv2QdQKomNJGeaOfeFcbCYCbeSfCdK3RdF rzURGDL2K8k7LC28VIUQMqFMdQick6ZLsVwFGcMRTpe0LopXyW2FayLpsH4B1MlA5M lwca2NYHsFqnHSlQ5VUjFBGm/cSPJlHy7zMLgFbWi38N5m7h+ygfOE5C3iXaj0mnF9 /2ZzJJfDWMlvHpAG5A7FQZJrBKT5K0F27dq5xoERRb7H/LOOSDAgM+OJ5epo3KFDZQ j8GMSrKQZ9G6g== X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id rKevt2I_vHs9; Thu, 30 Apr 2020 11:20:15 -0400 (EDT) Received: from mail03.efficios.com (mail03.efficios.com [167.114.26.124]) by mail.efficios.com (Postfix) with ESMTP id 83C8E28F5B1; Thu, 30 Apr 2020 11:20:15 -0400 (EDT) Date: Thu, 30 Apr 2020 11:20:15 -0400 (EDT) From: Mathieu Desnoyers To: Joerg Roedel , rostedt Cc: linux-kernel , Ingo Molnar , Thomas Gleixner , Peter Zijlstra , Borislav Petkov , Andrew Morton , Shile Zhang , Andy Lutomirski , "Rafael J. Wysocki" , Dave Hansen , Tzvetomir Stoyanov Message-ID: <2026887875.77814.1588260015439.JavaMail.zimbra@efficios.com> In-Reply-To: <20200430145057.GB8135@suse.de> References: <20200429054857.66e8e333@oasis.local.home> <20200429105941.GQ30814@suse.de> <20200429082854.6e1796b5@oasis.local.home> <20200429100731.201312a9@gandalf.local.home> <20200430141120.GA8135@suse.de> <20200430145057.GB8135@suse.de> Subject: Re: [RFC][PATCH] x86/mm: Sync all vmalloc mappings before text_poke() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [167.114.26.124] X-Mailer: Zimbra 8.8.15_GA_3918 (ZimbraWebClient - FF75 (Linux)/8.8.15_GA_3895) Thread-Topic: x86/mm: Sync all vmalloc mappings before text_poke() Thread-Index: S3gTR+3031U2pkjEqLvIr5kkofeFSw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- On Apr 30, 2020, at 10:50 AM, Joerg Roedel jroedel@suse.de wrote: > On Thu, Apr 30, 2020 at 04:11:20PM +0200, Joerg Roedel wrote: >> The page-fault handler calls a tracing function which again ends up in >> trace_event_ignore_this_pid(), where it faults again. From here on the CPU is in >> a page-fault loop, which continues until the stack overflows (with >> CONFIG_VMAP_STACK). > > Did some more testing to find out what this issue has to do with > > 763802b53a42 x86/mm: split vmalloc_sync_all() > > Above commit removes a call to vmalloc_sync_all() from the vmalloc > unmapping path, because that call caused severe performance regressions > on some workloads and was not needed on x86-64 anyway. > > But that call caused vmalloc_sync_all() to be called regularily on > x86-64 machines, so that all page-tables were more likely to be in sync. > > The call was introduced by commit > > 3f8fd02b1bf1 mm/vmalloc: Sync unmappings in __purge_vmap_area_lazy() > > to fix a correctness issue on x86-32 PAE systems, which also need > unmappings of large pages in the vmalloc area to be synchronized. > > This additional call to vmalloc_sync_all() did hide the problem. I > verified it by reverting both of the above commits on v5.7-rc3 and > testing on that kernel. The problem is reproducible there too, the box > hangs hard. > > So the underlying problem is that a vmalloc()'ed tracing buffer is used > to trace the page-fault handler, so that it has no chance of faulting in > the buffer address to poking_mm and maybe other PGDs. > > The right fix is to call vmalloc_sync_mappings() right after allocating > tracing or perf buffers via v[zm]alloc(). Either right after allocation, or right before making the vmalloc'd data structure visible to the instrumentation. In the case of the pid filter, that would be the rcu_assign_pointer() which publishes the new pid filter table. As long as vmalloc_sync_mappings() is performed somewhere *between* allocation and publishing the pointer for instrumentation, it's fine. I'll let Steven decide on which approach works best for him. Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com