Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2030559ybz; Thu, 30 Apr 2020 09:37:26 -0700 (PDT) X-Google-Smtp-Source: APiQypKEGl8iUdyc4T1Y6NfAEwb9c5K45GkbarT6YwJ8SkXKNKDBEsP4Pij5BcBrSPyXBPP1ceCe X-Received: by 2002:a05:6402:14c1:: with SMTP id f1mr3569020edx.221.1588264646048; Thu, 30 Apr 2020 09:37:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588264646; cv=none; d=google.com; s=arc-20160816; b=ipv/Uvc0Lw8vKSgSY6ziBeYhSytWosgassY5uBhxnkyhbu5qBSOiZ83UQH3oeWYTAI FfbU8t7WhAqGQs43aP1FdyVXvVhlDayENpjACmZZ6978EchpU75cf/RgBxBqjgXNdByl 2TOV2ALcZx6brPyGLVQBCoOgi60Eef5D/xTuCC0HXEgMgisr4AoTKj91hVIAavgytw5+ aj7Nz+FtIwwG/x3k7W7aJ9qyLr0BDjTkAYnGjN3xn/ZwlcaXubJNiXG53p7nWJwejxQl NzSipW5sXJOkDsZUxtzutbU/sC0RNhfvBUQhnqrESkfGRfCYd+46vkDBgxPq+1NfR4/w xOrA== 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=oP0ySd/C10g2du7jih56rgqzcsTpAP1agLKm0fyXMSg=; b=AVKyk5wFpp2PxEnonJIpZDAV4T2zc04C+s7xFPY2CSh3OfCTNQgC592wA+x6UKYjfh OWy1g+ZRCcXszpPm4tIxklHg2Win1pnfUCVARI19F8vAAjoWUNkChAuzOmIKUF/RLLUW ++yRLxRFaAZFteKtMt1kwZM2Dk+7KsPMxtjFqjXgH3UInb/mx3RJvfnO11wMIuzYt5MG sB+ZwEKzPLcWf3/YAvQ1HSJAGxd7QUgpXHck3dg+82b44Nc8Zrb3rhyS/mcAlOeybYuI K6g5hbXBgJYMC/Vjkj0pxRFd1PzTsqKUWgODMFhjqlw5bINo8Ne5mqmZeXq/O157puIN fbCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=OtKLuo67; 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 c10si125290edn.51.2020.04.30.09.37.02; Thu, 30 Apr 2020 09:37: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=OtKLuo67; 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 S1726477AbgD3Qfg (ORCPT + 99 others); Thu, 30 Apr 2020 12:35:36 -0400 Received: from mail.efficios.com ([167.114.26.124]:43716 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726336AbgD3Qff (ORCPT ); Thu, 30 Apr 2020 12:35:35 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id E540228FB75; Thu, 30 Apr 2020 12:35:34 -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 z1GqY8BLFzv7; Thu, 30 Apr 2020 12:35:34 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 9977C28F7CF; Thu, 30 Apr 2020 12:35:34 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 9977C28F7CF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1588264534; bh=oP0ySd/C10g2du7jih56rgqzcsTpAP1agLKm0fyXMSg=; h=Date:From:To:Message-ID:MIME-Version; b=OtKLuo67yS2RuQWnC379KkWAVdoX7xysKD2DDs9KBqsCM5y7ISSnJ+RfrUrWBXx8E WhkRh8+J3xXGLy/K9srCl4wwXcOgF0n1UjM+tr8/No/DvhC/GzjoIrD5wJQ3+SsBtw ikS0c641NEDSe509SeazXd8XfjdmnC2JqUa9g908q5phrsgll0TAiXbT9rXraZMiCt 4NJtMGIM5Jy1EJLc6CJvWz6rq0JRm7GJMG0a41UXVwX04RLJ4P0J2csLFcq3gl6+uP vn/qDqP2UiuwtRIupwIjmUOGuBPgmwimRAyJKL6pK6UfcY+67YTHB9odtAcPNP8rTc Vcg5t07undrrQ== 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 n6ykwUjOdPE1; Thu, 30 Apr 2020 12:35:34 -0400 (EDT) Received: from mail03.efficios.com (mail03.efficios.com [167.114.26.124]) by mail.efficios.com (Postfix) with ESMTP id 897CE290002; Thu, 30 Apr 2020 12:35:34 -0400 (EDT) Date: Thu, 30 Apr 2020 12:35:34 -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: <1877450632.77955.1588264534446.JavaMail.zimbra@efficios.com> In-Reply-To: <20200430123034.5705cd47@gandalf.local.home> References: <20200429054857.66e8e333@oasis.local.home> <20200429100731.201312a9@gandalf.local.home> <20200430141120.GA8135@suse.de> <20200430145057.GB8135@suse.de> <2026887875.77814.1588260015439.JavaMail.zimbra@efficios.com> <20200430121627.682061e2@gandalf.local.home> <947455570.77870.1588263502669.JavaMail.zimbra@efficios.com> <20200430123034.5705cd47@gandalf.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: +PuMHowgGmPM1/VUMnVVDDjIrQWjJg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- On Apr 30, 2020, at 12:30 PM, rostedt rostedt@goodmis.org wrote: > On Thu, 30 Apr 2020 12:18:22 -0400 (EDT) > Mathieu Desnoyers wrote: > >> ----- On Apr 30, 2020, at 12:16 PM, rostedt rostedt@goodmis.org wrote: >> >> > On Thu, 30 Apr 2020 11:20:15 -0400 (EDT) >> > Mathieu Desnoyers wrote: >> > >> >> > 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. >> > >> > As stated in the other email, I don't see it having anything to do with >> > vmalloc, but with the per_cpu() allocation. I'll test this theory out by >> > not even allocating the pid masks and touching the per cpu data at every >> > event to see if it crashes. >> >> As pointed out in my other email, per-cpu allocation uses vmalloc when >> size > PAGE_SIZE. > > And as I replied: > > buf->data = alloc_percpu(struct trace_array_cpu); > > struct trace_array_cpu { > atomic_t disabled; > void *buffer_page; /* ring buffer spare */ > > unsigned long entries; > unsigned long saved_latency; > unsigned long critical_start; > unsigned long critical_end; > unsigned long critical_sequence; > unsigned long nice; > unsigned long policy; > unsigned long rt_priority; > unsigned long skipped_entries; > u64 preempt_timestamp; > pid_t pid; > kuid_t uid; > char comm[TASK_COMM_LEN]; > > bool ignore_pid; > #ifdef CONFIG_FUNCTION_TRACER > bool ftrace_ignore_pid; > #endif > }; > > That doesn't look bigger than PAGE_SIZE to me. Let me point you to: pcpu_alloc() calling pcpu_create_chunk() which is then responsible for calling the underlying pcpu_mem_zalloc() which then uses vmalloc. So batching those allocations can be responsible for using vmalloc'd memory rather than kmalloc'd even though the allocation size is smaller than 4kB. Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com