Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp650124ybj; Tue, 5 May 2020 05:33:39 -0700 (PDT) X-Google-Smtp-Source: APiQypLwVb20TP5dDZfhvL+TqR+aCm0mAhu45qcMAmENeolqu3f3GhrwUFlBxKllarL8kpDT8PTo X-Received: by 2002:a17:906:970e:: with SMTP id k14mr2496537ejx.202.1588682019487; Tue, 05 May 2020 05:33:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588682019; cv=none; d=google.com; s=arc-20160816; b=STSL9SjJBVl1LFJOtdQDaWbwYp65oxxuq8MVMSNNiUZVJY4xl7ClqAz4QvSXjQgaw0 5J9wOdR28OGcQeM8H4hcTB3bOYrvNmgP6Pu9m7w2POSDVAwJfpWv4vnQ6ReeOlkIiECb E1i89dwbAdYCQLzGNSoa9B+Im/OXlVt8ZA4F0rgwmD5rSXAqkFLDWGJL1BhRVyp1vm+X tmwVn1iOvM1sD0MXkWK5Wbb5nUmByVRPhudPA54gTQDBFAzVj+9/niOVkccS6XggzRzF wnPuH0DmQJY5Drx7+OFs4AZPkxdTwB7YIWtJs1SSIMGZlpajxPGr2X/9e5qN7KBvT6YZ MFmA== 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:from:date; bh=+LCtD5QY81ZoW/XZN/GwzEu1Fy2IE4nYl+1+Y6d1zHM=; b=l7/eNcBcNdMM8KmCkyu+xuL34Y/NgpHh9HwLMrzk5RgfMTthQ6f0bId0SnrDQ+dMNS xEsBSNLFw/fFFXmenSt4br6OyrT6d4pedaeKR/OehFhFmYeb3U7FAwydSCcKgG9a/MEA y4PBz6XrLZmjnIYAhrhCV82fc+K/1ycAmyEosamEv99Zal3rxEbSgFH62CZU5HXMJHmH n1wr9ZoR5OvcxAaw91DIRWY7CJjC7B0vfOR2pn6q8l5joxa3CPke0T5UWoKk0dDtqcKE Ht/NWxhNScKjYUzM8KudlbhrzyHqVoanhMlSVgsPTW5t/87rHWZ9jwUHj8oHBhr1zVc/ i95g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l5si1007705ejg.164.2020.05.05.05.33.16; Tue, 05 May 2020 05:33:39 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728857AbgEEMbt (ORCPT + 99 others); Tue, 5 May 2020 08:31:49 -0400 Received: from mx2.suse.de ([195.135.220.15]:45912 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728804AbgEEMbt (ORCPT ); Tue, 5 May 2020 08:31:49 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id BD465AB89; Tue, 5 May 2020 12:31:49 +0000 (UTC) Date: Tue, 5 May 2020 14:31:44 +0200 From: Joerg Roedel To: Steven Rostedt Cc: Mathieu Desnoyers , linux-kernel , Ingo Molnar , Thomas Gleixner , Peter Zijlstra , Borislav Petkov , Andrew Morton , Shile Zhang , Andy Lutomirski , "Rafael J. Wysocki" , Dave Hansen , Tzvetomir Stoyanov Subject: [PATCH] tracing: Call vmalloc_sync_mappings() after alloc_percpu() Message-ID: <20200505123144.GM8135@suse.de> References: <20200430141120.GA8135@suse.de> <20200430121136.6d7aeb22@gandalf.local.home> <20200430191434.GC8135@suse.de> <20200430211308.74a994dc@oasis.local.home> <1902703609.78863.1588300015661.JavaMail.zimbra@efficios.com> <20200430223919.50861011@gandalf.local.home> <20200504151236.GI8135@suse.de> <20200504134042.178409c3@gandalf.local.home> <20200504183832.GL8135@suse.de> <20200504151006.69d2a16c@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200504151006.69d2a16c@gandalf.local.home> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 04, 2020 at 03:10:06PM -0400, Steven Rostedt wrote: > I'm fine with adding it to the tracing code (with that ridiculous > comment! ;-) > > I'll even tag is as stable, but again, it's uncertain what commit that it > "fixes". Okay, so here it is. It fixes the issue for me and doesn't cause any lockdep splats on my machine. I am not sure how far this needs to be backported via stable, so I didn't specify it. Same with a Fixes tag. Oh, and I added your comment :-) (which makes up most of the added lines, so feel free to change authorship to you). Regards, Joerg From a265290761dc9d87d35892dc821fd0f5c99f8b34 Mon Sep 17 00:00:00 2001 From: Joerg Roedel Date: Tue, 5 May 2020 14:17:57 +0200 Subject: [PATCH] tracing: Call vmalloc_sync_mappings() after alloc_percpu() Tracing code allocates percpu memory which is touched when trace events happen. When the events happen in the page-fault handler and per-cpu memory needs to be faulted in, the page-fault on per-cpu memory might never complete. Call vmalloc_sync_mappings() after allocating the runtime per-cpu buffers to make sure they are mapped when the page-fault handler tries to access them. This is not a nice solution, but the best fix until the vmalloc_sync_mappings/unmappings() interface can be ripped out of the kernel. Cc: stable@vger.kernel.org Signed-off-by: Joerg Roedel --- kernel/trace/trace.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 8d2b98812625..0fc56063fcca 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -8525,6 +8525,19 @@ static int allocate_trace_buffers(struct trace_array *tr, int size) */ allocate_snapshot = false; #endif + + /* + * Because of some magic with the way alloc_percpu() works on + * x86_64, we need to synchronize the pgd of all the tables, + * otherwise the trace events that happen in x86_64 page fault + * handlers can't cope with accessing the chance that a + * alloc_percpu()'d memory might be touched in the page fault trace + * event. Oh, and we need to audit all alloc_percpu() and vmalloc() + * calls in tracing, because something might get triggered within a + * page fault trace event! + */ + vmalloc_sync_mappings(); + return 0; } -- 2.12.3