Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp191722ybz; Thu, 30 Apr 2020 19:28:51 -0700 (PDT) X-Google-Smtp-Source: APiQypJyUDB/4ZHXEqpL1HRxFsGhJNehmpSSt0oMmiFO3nG+O/x0cOptFiLe+AMlftKpUOn4Mh8y X-Received: by 2002:a17:906:a2d3:: with SMTP id by19mr1357173ejb.370.1588300131072; Thu, 30 Apr 2020 19:28:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588300131; cv=none; d=google.com; s=arc-20160816; b=Mw4sEIDuDdfDXaLObPmJy1VnaiQX+6KiGU8behHE7DbvoMH7/FFE4GYdnQMN4EBE01 H5gtuv2zavH+xi6S7JAPhJIaiOzXkgij+g1ELRTFmJQtdd4xvEhDrbPc8hrR7Rz7UJ5y qQ1A0hp53DvIYCK+8/6mRMddGyj6ZmXRfvnM33EkQwLxtaZKsh4VTNUOutw3SOptvHMY 4YHTKPoTcHQc/nhgt8bqmdZCzROL+GyYQej1tXdtFZIU2ShlKcXYVt7xKK5xGGXJoaPx mYl6vHY70PBHsQbYorvk/neOwpqRYFuGODqaxTo/DOC2Mf+tdhqfcfnS52hkfSU+kji4 ym5A== 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=ZF3kaW85r3lYEjroSS8PIY6B5jzb4TIQMkaij/jZUlg=; b=rUmnef1EjdPOUid0LPMMIM164Wuo+sTipdEF1eNNVZ7tTP71J39WXbfa3RnuyJJJWy sHziudnGMfed87arHaTPp18v6ZHEFrbbSLDbj7kyKa8urceu7z+NV6vpb5yXVov4vA4N zKGfyGa4QZIjeTUsmmXeE9XQqxESXZgNNxbojVgdr0AOFD6pvHH7gvXfe1L7G2mjh/qB PeFFWVuJ4jIvOf/EYZdLAiz9ySn7vURiJ3WpU8MSM9yQ62Mx+q7EFydTQ5CS34kNT0Ue ToJ3aUMjM98RqGSO8Nvb+HqULdF0sihi+E52FxhsikNnV70LZhpcgwtr/cmrv9imPj01 KdWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=O70ZwJse; 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 k9si1029407edj.96.2020.04.30.19.28.26; Thu, 30 Apr 2020 19:28:51 -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=O70ZwJse; 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 S1728068AbgEAC05 (ORCPT + 99 others); Thu, 30 Apr 2020 22:26:57 -0400 Received: from mail.efficios.com ([167.114.26.124]:43244 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727949AbgEAC05 (ORCPT ); Thu, 30 Apr 2020 22:26:57 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 2F08029426E; Thu, 30 Apr 2020 22:26:56 -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 Sqt2ALfu7xgs; Thu, 30 Apr 2020 22:26:55 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id CC180294022; Thu, 30 Apr 2020 22:26:55 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com CC180294022 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1588300015; bh=ZF3kaW85r3lYEjroSS8PIY6B5jzb4TIQMkaij/jZUlg=; h=Date:From:To:Message-ID:MIME-Version; b=O70ZwJseNiVOWxRXsVh9uQ0MnsRF2OCSriMm4aV+c08qg5dcCG8Z6auJNKmHaapNN kwQexk93+gbCgsYeCiDTlIjWckc5+dNaNierSVF5LwG9Mtuby9OrN4yBxVlbPQ5+91 wyEnWeuXyt7VePkIn2JG3NXs1+ihc5BeIRLLJeMny3PdI0J88sYZ7Je0wZS0f/OrnY 1IctGUvp8w5lgqDM5L6dzodGGb6l4jhy6ssSBRLW7R2b8nEGBB/gNjuYCR75mDci/C Lf6Y2vDFGhn6Ln55ck3k3HpF0tZi8k02m3BxFBfHrwN5WBI5IaimaINlD4ENhGcU1X Ak7EULrfPJb0w== 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 ulcWaEYJbfqh; Thu, 30 Apr 2020 22:26:55 -0400 (EDT) Received: from mail03.efficios.com (mail03.efficios.com [167.114.26.124]) by mail.efficios.com (Postfix) with ESMTP id B8A8929401F; Thu, 30 Apr 2020 22:26:55 -0400 (EDT) Date: Thu, 30 Apr 2020 22:26:55 -0400 (EDT) From: Mathieu Desnoyers To: rostedt Cc: Joerg Roedel , 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: <1902703609.78863.1588300015661.JavaMail.zimbra@efficios.com> In-Reply-To: <20200430211308.74a994dc@oasis.local.home> References: <20200429054857.66e8e333@oasis.local.home> <20200429105941.GQ30814@suse.de> <20200429082854.6e1796b5@oasis.local.home> <20200429100731.201312a9@gandalf.local.home> <20200430141120.GA8135@suse.de> <20200430121136.6d7aeb22@gandalf.local.home> <20200430191434.GC8135@suse.de> <20200430211308.74a994dc@oasis.local.home> 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: kBddBN1oVQ4F/2TWc3Q4S/2/epDTaQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- On Apr 30, 2020, at 9:13 PM, rostedt rostedt@goodmis.org wrote: > [ Joerg, sending again this time not just to you. (hit reply to sender > and not reply to all). Feel free to resend what you wrote before to this ] > > On Thu, 30 Apr 2020 21:14:34 +0200 > Joerg Roedel wrote: > >> And alloc_percpu() calls down into pcpu_alloc(), which allocates new >> percpu chunks using vmalloc() on x86. And there we are again in the >> vmalloc area. > > So after a vmalloc() is made, should the page tables be synced? Why should it ? Usually, the page fault handler is able to resolve the resulting minor page faults lazily. > > This is a rather subtle bug, and I don't think it should be the caller of > percpu_alloc() that needs to call vmalloc_sync_mappings(). Who said tracing was easy ? ;-) > What's your suggestion for a fix? I know the question is not addressed to me, but here are my 2 cents: It's subtle because ftrace is tracing the page fault handler through tracepoints. It would not make sense to slow down all vmalloc or percpu_alloc() just because tracing recurses when tracing page faults. I think the right approach to solve this is to call vmalloc_sync_mappings() before any vmalloc'd memory ends up being observable by instrumentation. This can be achieved by adding a vmalloc_sync_mappings call on tracepoint registration like I proposed in my patchset a few week ago: https://lore.kernel.org/r/20200409193543.18115-2-mathieu.desnoyers@efficios.com The tracers just have to make sure they perform their vmalloc'd memory allocation before registering the tracepoint which can touch it, else they need to issue vmalloc_sync_mappings() on their own before making the newly allocated memory observable by instrumentation. This approach is not new: register_die_notifier() does exactly that today. Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com