Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1748533ybl; Sat, 11 Jan 2020 02:02:34 -0800 (PST) X-Google-Smtp-Source: APXvYqzwlBYKmkf9BfuOiqOT1XDAwbcQhkz2LVKyyyucM2kNOH8LfX7kVW1vommcG+dPJpNXvjg5 X-Received: by 2002:a9d:6b12:: with SMTP id g18mr5986700otp.211.1578736954463; Sat, 11 Jan 2020 02:02:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578736954; cv=none; d=google.com; s=arc-20160816; b=jACZraxc/69hZV45eI8DwEn1Vd3FDTKL6CFa0DdVN9U5KKWtvVk4SdOsp9w27hx//q 26Pq+IrPVD0JLbBGRxQ9iph5qUqAPTeyO+sEkdzp7U6cH25hA865P3YqWxeAoloskZlw V3b31sYXdlPtENrO/BUxc1zgWbMc/ZGzwyALDuEU+8uVwcS5c3F4GdSogSn9X5LTG5gN U7zFgQSxDXsHkDEy4kvtImfHbCe5t2LaNFdiW0shnTklglVJxYQTfxbOm9FvxMx/mbNS 1kaPVehLerz2m+rg6wujm/30CTFtq/UtcSxlQjp1Vc4nb2YM3uRki74HokxKPKOIaHut nvPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Zl0ToS9Fu0zdz5Tw7iJLLoXrdaoQOk29UWfp2JQPWhI=; b=q8rrbtqEhS1NtukB5z9/Xy3X8mvQWROmepDfOet8zUnQrB9Vp8XDO451xXEgZ6ABLK 03MKsxq60lADMlmAolXOXMJHWGLRh46qkOvHXi9/yxFaAb1hx6OMim5w2QaqSw0fTZNu npz1WiztgekDWj9WPcaMghP7YSB27sTpIffGJpmELDPg0tLKI+3UYPld96f2iT7xa1GX Ce8duSjCKIn6gNDX4/i4kulLjbLjV4xJcFkGpOFzOCp3H78RjHuaag0mh4Lcb6JgUAYG KNCKyDWRMTg2foVD4sTKgigcCoP7cGisrUY2pacU1eV/Twvf/qns97gbOQ8IuifiAf6v RmBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Vs1d7g04; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o206si2843354oih.143.2020.01.11.02.02.23; Sat, 11 Jan 2020 02:02:34 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Vs1d7g04; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729356AbgAKKAC (ORCPT + 99 others); Sat, 11 Jan 2020 05:00:02 -0500 Received: from mail.kernel.org ([198.145.29.99]:55378 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729133AbgAKJ77 (ORCPT ); Sat, 11 Jan 2020 04:59:59 -0500 Received: from localhost (unknown [62.119.166.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B612A20848; Sat, 11 Jan 2020 09:59:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578736798; bh=JFCUHKxyVKwgSL+NanAh19r9rBcLUNYoar4WgrPBQPA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vs1d7g04Ftg87jKWOp35PgenG/EgLCpwGkwTyeQPtsYbveYTkE++J6itIjZQNqxU9 baAVpw+DG/xJDsmWDDfh30oawQ7NHNtwZa0mTGNtZl8swTHE+6JzSjXm5kLLUF4RrF /JQU1TNKbcsuyyngsPsNWgglGNjT3xYsyFko8Fkg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Richter , Vasily Gorbik , Sasha Levin Subject: [PATCH 4.9 10/91] s390/cpum_sf: Avoid SBD overflow condition in irq handler Date: Sat, 11 Jan 2020 10:49:03 +0100 Message-Id: <20200111094846.581063465@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200111094844.748507863@linuxfoundation.org> References: <20200111094844.748507863@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Richter [ Upstream commit 0539ad0b22877225095d8adef0c376f52cc23834 ] The s390 CPU Measurement sampling facility has an overflow condition which fires when all entries in a SBD are used. The measurement alert interrupt is triggered and reads out all samples in this SDB. It then tests the successor SDB, if this SBD is not full, the interrupt handler does not read any samples at all from this SDB The design waits for the hardware to fill this SBD and then trigger another meassurement alert interrupt. This scheme works nicely until an perf_event_overflow() function call discards the sample due to a too high sampling rate. The interrupt handler has logic to read out a partially filled SDB when the perf event overflow condition in linux common code is met. This causes the CPUM sampling measurement hardware and the PMU device driver to operate on the same SBD's trailer entry. This should not happen. This can be seen here using this trace: cpumsf_pmu_add: tear:0xb5286000 hw_perf_event_update: sdbt 0xb5286000 full 1 over 0 flush_all:0 hw_perf_event_update: sdbt 0xb5286008 full 0 over 0 flush_all:0 above shows 1. interrupt hw_perf_event_update: sdbt 0xb5286008 full 1 over 0 flush_all:0 hw_perf_event_update: sdbt 0xb5286008 full 0 over 0 flush_all:0 above shows 2. interrupt ... this goes on fine until... hw_perf_event_update: sdbt 0xb5286068 full 1 over 0 flush_all:0 perf_push_sample1: overflow one or more samples read from the IRQ handler are rejected by perf_event_overflow() and the IRQ handler advances to the next SDB and modifies the trailer entry of a partially filled SDB. hw_perf_event_update: sdbt 0xb5286070 full 0 over 0 flush_all:1 timestamp: 14:32:52.519953 Next time the IRQ handler is called for this SDB the trailer entry shows an overflow count of 19 missed entries. hw_perf_event_update: sdbt 0xb5286070 full 1 over 19 flush_all:1 timestamp: 14:32:52.970058 Remove access to a follow on SDB when event overflow happened. Signed-off-by: Thomas Richter Signed-off-by: Vasily Gorbik Signed-off-by: Sasha Levin --- arch/s390/kernel/perf_cpum_sf.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/arch/s390/kernel/perf_cpum_sf.c b/arch/s390/kernel/perf_cpum_sf.c index 3b8e5a3d2d64..c62eb09b2ba7 100644 --- a/arch/s390/kernel/perf_cpum_sf.c +++ b/arch/s390/kernel/perf_cpum_sf.c @@ -1295,12 +1295,6 @@ static void hw_perf_event_update(struct perf_event *event, int flush_all) */ if (flush_all && done) break; - - /* If an event overflow happened, discard samples by - * processing any remaining sample-data-blocks. - */ - if (event_overflow) - flush_all = 1; } /* Account sample overflows in the event hardware structure */ -- 2.20.1