Received: by 2002:a05:7412:9c07:b0:fa:6e18:a558 with SMTP id lr7csp547810rdb; Sat, 27 Jan 2024 20:19:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IHtYxOw2JkyWnnUPawPo0aOZSpzNOhve+V1FjTMbniq9jBkPIHvj/Ouv7BlC2Co32rg0K39 X-Received: by 2002:a05:6870:56a2:b0:206:79a6:24d1 with SMTP id p34-20020a05687056a200b0020679a624d1mr2856906oao.55.1706415592605; Sat, 27 Jan 2024 20:19:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706415592; cv=pass; d=google.com; s=arc-20160816; b=ucmVeaiIfolED0sBcROSYVKTn1pkiMaSJnt34I7Mpu3cIuK+avrTdfOJGP+0sYBEWV 4/JDDpoizZjp2cjFptvN6q0Bh5NMC5ZxEL9/hxMVYG3L+0PDTLySoBNK/lOvijvs98b3 /re3g0NUy7T2a4xC87rdQAf/wIcMnLhyataw+mNoeDF41P+z6tACyaEFe6VnKV0PQHAl 77TfMqZx56Z1snXB6NmMg0WbfNLsTsROWdZsKoqoFfyj1iAm1X/kMHHK1Sdxlhnm2iZs m8jLY/wrK17eCebpIPOjkx4l1Yo52WGvcX13vtR/ymbpRoBdWVENkAWTITvUHh0Rzhn2 mY1g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=15t886RIABr313J9wigXhAHcQ7ucTJcHxOCOzS75ZHE=; fh=9fZAvdpJKLc2rTLaVNLhQbZrHng0POgfk2SZSGNYuqw=; b=q9ufawYZzLNqbEL4ABLJsnnVnzpq7jSzZWP39vtI/XKqegCWAOASXEgQY4iQv0W9x+ wl4gbrn+kvdY9HabaREekC2QNq8Qs3+o2+hXXsZEr3vu7LhiQaDIX+re5ipXUVIr7x6D gmwh42To4v30/nPVbrku+Qwuibw1pexwjaPBnNFcIWjgJH2u/SRs7rGW/GFCn/d0o4rb umQ29XFPOn9FXjs1IzTmfyaOU+SvHcDIsraUNx6GS/5rmuScGpR+LIK0fqDOvoI9yvsQ eHgLryxSX/slYryZ6KXxJ5sJb3BibKef/s6XpLvD6S3MFIBc7Xp/3IJ8PpMTkl46KUTk FXLg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="bsDweI7/"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-41526-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41526-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id h6-20020a656386000000b005d8bb714e79si1472111pgv.586.2024.01.27.20.19.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Jan 2024 20:19:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-41526-linux.lists.archive=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=@gmail.com header.s=20230601 header.b="bsDweI7/"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-41526-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41526-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 369FE284860 for ; Sun, 28 Jan 2024 04:19:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DB3A1539A; Sun, 28 Jan 2024 04:19:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bsDweI7/" Received: from mail-oo1-f51.google.com (mail-oo1-f51.google.com [209.85.161.51]) (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 A80B5469E; Sun, 28 Jan 2024 04:19:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706415585; cv=none; b=UedSX4UxHNSssfcAiGfInpEPR56lA9e5OjvumT0HQo34wY2S8Dy3bmczTgBCZU4PnCouRZ98d3TIom+1ANSBwQDBCPSq9YJxk48LnqvaS5ri+cxFU/pMAy+/tUS5c27z++TzFmi0aHHpsd2658bWbjPx3NoAN5wCPG0nNfA9ldI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706415585; c=relaxed/simple; bh=ouvRLb+Ds//L/skH9q1zWlfq8nHjlpo/XAlc5ITQhLs=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=bU7wTswN9YYMrqmTuDiebxCgyhdyQj71B7mTF4qAzYzdY8KDiYEq13360HsNHfJ7J1Ei+JsTk95CeQ6hgEXSrmhBL7IUYs2ONT/qh4QMrE/wX1++7Noqzuk73sCGgOz9OskP7057bFYx02bKULztan1co6agVdQwXSnLkiCDc9A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bsDweI7/; arc=none smtp.client-ip=209.85.161.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oo1-f51.google.com with SMTP id 006d021491bc7-59502aa878aso887244eaf.1; Sat, 27 Jan 2024 20:19:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706415582; x=1707020382; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=15t886RIABr313J9wigXhAHcQ7ucTJcHxOCOzS75ZHE=; b=bsDweI7/nGrXbmx3KMtbaaTJzJPPb1ag2iHaFAARU3rZEB+6eLkuG11MGygoP8ksuD dFfwgZFl38jLezGlJ7oM4m7QNcjv3ruVaq7K4alC1s+ogBc+HU1cnDRxRRF2j1SYzWaJ wgG58MIISfrbR8Epg/e7oli2q2wPp5Ac0MjeKRVLxmJE1lom+ko4k6o6MdYLDfckRYgc 9NEB3fgbu4hqDBeoUQmAjtfjYvBhcL0SYRCR0A1eWOJAl14OmaBARFoKGQzHkyqvzC4y A8CWfsE7yaniEFktQI+ArsfpJgR/RIyYOIthGt4GeTGS2xNMPPF7fsdlNViOSDwH2BEa kZSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706415582; x=1707020382; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=15t886RIABr313J9wigXhAHcQ7ucTJcHxOCOzS75ZHE=; b=fD9/yp+bKc7p7Lvy+Wnx4TPH2nfxK8P5DFPKW26FgXwOr2c7tkyvrgAMwT1B55Jx+y YC1+V/B3s2cZ7RfCBmN/muycb4QTvT72s/OOFNNlsvdVJOg2heOMcNlrXdCAVvKKxT4I mgxnuaFUaHlaYrF0u3cS1EkVnhiV/t1wwlOYh2R0rx3cfIz2t1dG87rPVzsVvMQ9a2t/ 7icyU6r/f11uQXfG6ZRf5heKukQpnagDqfbCKcbYu2Tdy14HLbH8GjfmmAZQc3E2FRDh u5+NofUJ8M2Buio6K2hOzyp431KHiQBvhRXeNRnmOXWwgTMZpo7GrxVcfdlz90I0Rf/g 5NqQ== X-Gm-Message-State: AOJu0Yy6F206bBonPAEzyQy7nf7NKHp4qZZV+MSUrFEL3rKI/wT9/vV0 GXhGixLOG9CAaVv+MeEZQ/tvdJMcTKyJJORYcDXIN0UtpHJ14cnl X-Received: by 2002:a05:6359:1501:b0:175:c16b:126f with SMTP id jt1-20020a056359150100b00175c16b126fmr2599450rwb.56.1706415582367; Sat, 27 Jan 2024 20:19:42 -0800 (PST) Received: from ubuntu.localdomain ([219.143.159.9]) by smtp.gmail.com with ESMTPSA id x15-20020a17090a164f00b00295210e5a9asm2442047pje.48.2024.01.27.20.19.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Jan 2024 20:19:41 -0800 (PST) From: Donglin Peng To: peterz@infradead.org Cc: jolsa@kernel.org, wangnan0@huawei.com, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Donglin Peng Subject: [PATCH] perf/ring-buffer: refactor code of reading the value of data_tail Date: Sat, 27 Jan 2024 20:19:35 -0800 Message-Id: <20240128041935.513800-1-dolinux.peng@gmail.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The tail variable will only be accessed when overwrite is 0, so we can put the assignment statement in the if branch. Fixes: d1b26c70246b ("perf/ring_buffer: Prepare writing into the ring-buffer from the end") Signed-off-by: Donglin Peng --- kernel/events/ring_buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c index 60ed43d1c29e..86b150a822b7 100644 --- a/kernel/events/ring_buffer.c +++ b/kernel/events/ring_buffer.c @@ -194,8 +194,8 @@ __perf_output_begin(struct perf_output_handle *handle, offset = local_read(&rb->head); do { head = offset; - tail = READ_ONCE(rb->user_page->data_tail); if (!rb->overwrite) { + tail = READ_ONCE(rb->user_page->data_tail); if (unlikely(!ring_buffer_has_space(head, tail, perf_data_size(rb), size, backward))) -- 2.25.1