Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1628267ybi; Sat, 8 Jun 2019 14:28:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqzqO794qFSU/GgUAfTobk7zudI7iw0nN+BzE1d684ws1q0hG91jAmOfe0E4cPm9gAZ2zn+R X-Received: by 2002:a17:90a:26cf:: with SMTP id m73mr12822936pje.90.1560029324857; Sat, 08 Jun 2019 14:28:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560029324; cv=none; d=google.com; s=arc-20160816; b=JfzsRj+tspoz/sZN+59/f+8THdaYRf00mA9/+fX8COfSWmWO43qC2s9jTrq+gFxwDs o017g35Wn6nnBLt8hOiJ7pRPo6/wwC563kJ/jl2GrcIaR0N4fInn5qjJ2UIbusSYCeGb 2in2eSIKPIQUX5VIcwdn1ewxUwFvc7DhE0JQcOilSq5rfxtdTAsuzTmTJEYf7D3hhXOn Cp65TxS5eeaZPNFxuEfZXlZ8cNlLMKW0vtgE0s1OVr7DMJ9ZQshUmcuwxDxKDORJ6WPu HXc9ZtKDHN7bAXqBfmX4jgtfzZ+ErGIgIvJ+tLNB3g1sUpFOsMhggs4Of+w92AeQLUm8 IBNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:dkim-signature:dkim-filter; bh=3DOInXZ4iRK6cg1I2XjHTZPy+Dj6ZJrIvcfxmr8ebZU=; b=tMeqoGFO1ocC41wblrhefflUmBWY7IX8ovuO5W+4+JfW/DnklnBE9rJ2rWAa3X8Zlm b8j8vvrzfMXoN7pC0hUYGN5l4KUQa6P7kQoUOUN7O6YgoJbw2BF5VH7asNMbCvfpRDxO DrhJkP3JdqNhM1I0FyLuEwQlr4JMDQvbRft1cx9VGiC/0nmbOlUJeVwImqBPBVxLLXll 7zXbCGozhNrm/u5MuLd3My8VQ873WZ++CJ1FC69dwxdCHzKdBelR39tWnBvnVZP97Qy6 GM0ALqA0vZBnDAC7EVm/tRajyAHKTNHywcvOhCv5eAJqtmQA3LY6as90qM3U1ZHT9fuA 7fOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2019051801 header.b=LPLyhkmG; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y22si5404404pgj.402.2019.06.08.14.28.29; Sat, 08 Jun 2019 14:28:44 -0700 (PDT) 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=@zytor.com header.s=2019051801 header.b=LPLyhkmG; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727586AbfFHV01 (ORCPT + 99 others); Sat, 8 Jun 2019 17:26:27 -0400 Received: from terminus.zytor.com ([198.137.202.136]:53153 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727456AbfFHV00 (ORCPT ); Sat, 8 Jun 2019 17:26:26 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x58LQ5S33145369 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sat, 8 Jun 2019 14:26:05 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x58LQ5S33145369 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019051801; t=1560029166; bh=3DOInXZ4iRK6cg1I2XjHTZPy+Dj6ZJrIvcfxmr8ebZU=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=LPLyhkmGt7GZeOLoBbx56HA15wcdl7uQWbXOtfDpr2MaP8EJpFx6dGTTomSOs9Ymv tXDcJn4jw6oCyJ3YKGqDTb/hPwtSqxiwzVgRrReKfRzs7ZAxTH5YEA6fbxX50E/NZ1 YZ3EJiYA9I/Epz7U1vrh7nwyBos47RZzTXe2c6YVE3Cb/Tsn1LRO5pOgMhM04IpBU7 lkLCvDzP+F2dAQVolNDGmB9IMhSvmrfQhc2biINfTEan4foDBR62rX8t3QNN0D1XJK UGY74GHLcV6j0KDCsJY9D68mGyeNh9D4Owf8MgBVV30vIbnJcCEgpAkEY06Tgs41Kn ocBcvL5GlEOXQ== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x58LQ46A3145366; Sat, 8 Jun 2019 14:26:04 -0700 Date: Sat, 8 Jun 2019 14:26:04 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Borislav Petkov Message-ID: Cc: chao.wang@ucloud.cn, bp@suse.de, mingo@kernel.org, linux-kernel@vger.kernel.org, tony.luck@intel.com, tglx@linutronix.de, hpa@zytor.com Reply-To: linux-kernel@vger.kernel.org, mingo@kernel.org, bp@suse.de, chao.wang@ucloud.cn, hpa@zytor.com, tglx@linutronix.de, tony.luck@intel.com In-Reply-To: <20190418034115.75954-3-chao.wang@ucloud.cn> References: <20190418034115.75954-3-chao.wang@ucloud.cn> To: linux-tip-commits@vger.kernel.org Subject: [tip:ras/core] RAS/CEC: Check count_threshold unconditionally Git-Commit-ID: de0e0624d86ff9fc512dedb297f8978698abf21a X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.4 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_96_Q,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: de0e0624d86ff9fc512dedb297f8978698abf21a Gitweb: https://git.kernel.org/tip/de0e0624d86ff9fc512dedb297f8978698abf21a Author: Borislav Petkov AuthorDate: Sat, 20 Apr 2019 14:06:37 +0200 Committer: Borislav Petkov CommitDate: Sat, 8 Jun 2019 17:33:10 +0200 RAS/CEC: Check count_threshold unconditionally The count_threshold should be checked unconditionally, after insertion too, so that a count_threshold value of 1 can cause an immediate offlining. I.e., offline the page on the *first* error encountered. Add comments to make it clear what cec_add_elem() does, while at it. Reported-by: WANG Chao Signed-off-by: Borislav Petkov Cc: Tony Luck Cc: linux-edac@vger.kernel.org Link: https://lkml.kernel.org/r/20190418034115.75954-3-chao.wang@ucloud.cn --- drivers/ras/cec.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/drivers/ras/cec.c b/drivers/ras/cec.c index f5795adc5a6e..73a975c26f9f 100644 --- a/drivers/ras/cec.c +++ b/drivers/ras/cec.c @@ -294,6 +294,7 @@ int cec_add_elem(u64 pfn) ca->ces_entered++; + /* Array full, free the LRU slot. */ if (ca->n == MAX_ELEMS) WARN_ON(!del_lru_elem_unlocked(ca)); @@ -306,24 +307,17 @@ int cec_add_elem(u64 pfn) (void *)&ca->array[to], (ca->n - to) * sizeof(u64)); - ca->array[to] = (pfn << PAGE_SHIFT) | - (DECAY_MASK << COUNT_BITS) | 1; - + ca->array[to] = pfn << PAGE_SHIFT; ca->n++; - - ret = 0; - - goto decay; } - count = COUNT(ca->array[to]); - - if (count < count_threshold) { - ca->array[to] |= (DECAY_MASK << COUNT_BITS); - ca->array[to]++; + /* Add/refresh element generation and increment count */ + ca->array[to] |= DECAY_MASK << COUNT_BITS; + ca->array[to]++; - ret = 0; - } else { + /* Check action threshold and soft-offline, if reached. */ + count = COUNT(ca->array[to]); + if (count >= count_threshold) { u64 pfn = ca->array[to] >> PAGE_SHIFT; if (!pfn_valid(pfn)) { @@ -338,15 +332,14 @@ int cec_add_elem(u64 pfn) del_elem(ca, to); /* - * Return a >0 value to denote that we've reached the offlining - * threshold. + * Return a >0 value to callers, to denote that we've reached + * the offlining threshold. */ ret = 1; goto unlock; } -decay: ca->decay_count++; if (ca->decay_count >= CLEAN_ELEMS)