From patchwork Mon Feb 5 16:34:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Donnefort X-Patchwork-Id: 196921 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp991073dyb; Mon, 5 Feb 2024 08:34:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IHlRcqvnoSHpvLoVkz4GY7VniSlIqWu98A/5T+iE0lAY8S4vBymrNpZCiLH+9cDR6UwKJhh X-Received: by 2002:a17:90a:5aa2:b0:290:69e2:de18 with SMTP id n31-20020a17090a5aa200b0029069e2de18mr15141567pji.41.1707150887822; Mon, 05 Feb 2024 08:34:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707150887; cv=pass; d=google.com; s=arc-20160816; b=Ta3eKSQ9ObFCfTf1Bs0hD9PrSvAUucQ1iVRWRUPIsSodukXoPNtjh+ykzPff+HZcJz Iu0vEOFyhMSrfunhnK2i2iSwxRZtbp9Ro/lOeBgNge01Yt1/xxm5xZYyhJRoiKsIsM6j zB9plfpA6x2/dQ89rbq9JN4N4/AgK/iSRbKXGTJ0RdYE5lm0YFqm5R2p+pt5/3gj0fp8 Pw7uiVkeXGRVOi80oy9JQYCOVWEce0wbA7UyaJOpulGoWTbPhccOcvlNT7VP71v2YaqG +2Se8EIvbNS96eIql/LQS5Tq7mCSyFrX18v8PzkBWeAMBgeYBez8EZUAvsJlMLDfqH/R /LaA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=80zEqO4cAfaVKiES2NvcSNlY10tKCHIehQe+RxguKbw=; fh=gTEz/bl9oO0o7KKySqMpm2yop3crSEcn3mUZ7ICxBzA=; b=dlsx1SSrt+hI0uiREjQ/KufDYjkL6hJ5dW/02ErvOUpVen2Q9qij+p9ScGHS6kmO27 AJN6BTRhXQ31GljfMfaQEQH/sopdvUU9HY8aFKU/c6kcYKKPQzEvocEBz42vDwaa19IA N2TD4koG4eJVXU5QDqQYCPiX12lr/uhYZcQerPnpSq7/azjshgp30t4Bk9hTDo9ugDnX QjennzAzzAGSnjqRhoqlz+ai2eGmxkyjhs/8pSuTS+3AJ4MjpidQRpJDsoKItJiZYWmB Ir4WxKHUOY8L1RUEuqZ4QPSv4P8gL7PFTKcjxMvk6XM3sRcMoMkAqWD/1q2dtcj956Rr IF1g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="GkW9fd/V"; arc=pass (i=1 spf=pass spfdomain=flex--vdonnefort.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-53015-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53015-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=1; AJvYcCXDmLnJarz+7BUhpwIUr3Cuz3qNmTjkrQ7rfvSekYHs8t52EnEn8/rCurs+5a2GuVhJIzpYRL4S9iArtcmo5S9j+aHpKA== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id jh9-20020a170903328900b001d72907f487si88466plb.56.2024.02.05.08.34.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 08:34:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53015-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="GkW9fd/V"; arc=pass (i=1 spf=pass spfdomain=flex--vdonnefort.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-53015-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53015-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7CBE2284F89 for ; Mon, 5 Feb 2024 16:34:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B898D3FE48; Mon, 5 Feb 2024 16:34:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="GkW9fd/V" Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 801B42C191 for ; Mon, 5 Feb 2024 16:34:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707150862; cv=none; b=Pc04d49OTCiZNtp6kn/Rsi+fMphzDyqSgh7LRVLeCNfAqWq7otL14DBa5MYPgF8bq26q2v9jSj2EbGJxNrKmd7dLSwnhgcmgvZvRzWZzgLYlBnqA/ChMfL/m3PXxVjFfSIUpD2XX3l8CzG33DMXo38G5/iM7IugqnVNDm6jf/tU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707150862; c=relaxed/simple; bh=1fJD7FqdEtsCCOZb17HnRU5d9h5a6C+oEF9lp8cXViE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Ubji0zUnDcd7oVERpJGIUYzKrYhWOkC6mGjKVWdJvZWWXl48+ErceMrtu88+//KywoWsvJcxIs2J6sBS2hQGGke3fDl29OXXIetWY1fu4YLedcQlhgJGLfhwM+ogyfOlLsaVBkAlxiqnmA29VEwM4FoL2roLFLnrerYd8yB+o8E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--vdonnefort.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=GkW9fd/V; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--vdonnefort.bounces.google.com Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-60444884b7dso24607947b3.1 for ; Mon, 05 Feb 2024 08:34:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707150859; x=1707755659; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=80zEqO4cAfaVKiES2NvcSNlY10tKCHIehQe+RxguKbw=; b=GkW9fd/V6hxg852IQfJ1wDYoyBYECO+DM/8+k70qEs8E1EDe4c3kVTFiaC+V7IMFq8 h2IuN9gW1WJFKSpRBnX8b8Yd+pHqgO5XexOjsSuh6F0xr5IsQ3MguKBY9bkN9ypI73pm NBsCv8TWZqeJlN/oFhByC4aDI3y/4JbYK64PJbDuJPtHOzFU+ksWbx0ty2g1BnfUSGDm /cUK9TQNaLvVquo4Vfot2X085loqKBMLYNXfztmGmoY7rgO0lh13t5GQl1bjyJaUVB/A 58BNYWxswdfWtsf30cWNk3e+CCjGw8onB8TLJ8DDaMIpu70fmT8Jofab0dGp1M31BbjI L2Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707150859; x=1707755659; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=80zEqO4cAfaVKiES2NvcSNlY10tKCHIehQe+RxguKbw=; b=tdFuqMMYF17F03v5DwAl3TH7Hr48r17guMXJ4b7ab7r7g//faMRcM/tfEqvpEcLuIj HpjV8biDjdaxzp+pBjPjdkwBjHF3KMRZhGglrIispGO92QMQUTrd29ZItOSsxfDL/4Jr fQS7/eOrcezKbYYn9YVLAxdWlB9ACEPqBmztZHSyE7xULuhQNUNw16jIg9WqplEpl1AI N3vJ7x0UKHGSMoeSfsM6IUUlUnmXKgB17sOU/TrNN86gxxooqyzr9Wss9ObInWU/+ukU L3cbjAs5sjvMDOz+CsBsDA3ZDwc04xeXZSeJNT3U54iKpUTHe/VmuPnbDooAGwQPeknu zg5g== X-Gm-Message-State: AOJu0YxqXNXwf9FOKOHjbJW/4VH29Dluqoq/RwznppoHgCckqH4Nd26p CmUomEWeeSrnlC5aWXy2vPMQr7IrcLACmlURVs7+OyM89B2tWFB4jdSpLhm0VPNWCQb3/f99Flx hKjZWX74mfq5rKHA68w== X-Received: from vdonnefort.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:2eea]) (user=vdonnefort job=sendgmr) by 2002:a05:6902:138f:b0:dc6:dd74:de68 with SMTP id x15-20020a056902138f00b00dc6dd74de68mr457659ybu.12.1707150859536; Mon, 05 Feb 2024 08:34:19 -0800 (PST) Date: Mon, 5 Feb 2024 16:34:05 +0000 In-Reply-To: <20240205163410.2296552-1-vdonnefort@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240205163410.2296552-1-vdonnefort@google.com> X-Mailer: git-send-email 2.43.0.594.gd9cf4e227d-goog Message-ID: <20240205163410.2296552-2-vdonnefort@google.com> Subject: [PATCH v14 1/6] ring-buffer: Zero ring-buffer sub-buffers From: Vincent Donnefort To: rostedt@goodmis.org, mhiramat@kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: mathieu.desnoyers@efficios.com, kernel-team@android.com, Vincent Donnefort X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790077449237174469 X-GMAIL-MSGID: 1790077449237174469 In preparation for the ring-buffer memory mapping where each subbuf will be accessible to user-space, zero all the page allocations. Signed-off-by: Vincent Donnefort Reviewed-by: Masami Hiramatsu (Google) diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index fd4bfe3ecf01..ca796675c0a1 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c @@ -1472,7 +1472,8 @@ static int __rb_allocate_pages(struct ring_buffer_per_cpu *cpu_buffer, list_add(&bpage->list, pages); - page = alloc_pages_node(cpu_to_node(cpu_buffer->cpu), mflags, + page = alloc_pages_node(cpu_to_node(cpu_buffer->cpu), + mflags | __GFP_ZERO, cpu_buffer->buffer->subbuf_order); if (!page) goto free_pages; @@ -1557,7 +1558,8 @@ rb_allocate_cpu_buffer(struct trace_buffer *buffer, long nr_pages, int cpu) cpu_buffer->reader_page = bpage; - page = alloc_pages_node(cpu_to_node(cpu), GFP_KERNEL, cpu_buffer->buffer->subbuf_order); + page = alloc_pages_node(cpu_to_node(cpu), GFP_KERNEL | __GFP_ZERO, + cpu_buffer->buffer->subbuf_order); if (!page) goto fail_free_reader; bpage->page = page_address(page); @@ -5525,7 +5527,8 @@ ring_buffer_alloc_read_page(struct trace_buffer *buffer, int cpu) if (bpage->data) goto out; - page = alloc_pages_node(cpu_to_node(cpu), GFP_KERNEL | __GFP_NORETRY, + page = alloc_pages_node(cpu_to_node(cpu), + GFP_KERNEL | __GFP_NORETRY | __GFP_ZERO, cpu_buffer->buffer->subbuf_order); if (!page) { kfree(bpage);