From: "Levin, Alexander (Sasha Levin)" <alexander.levin@verizon.com>
To: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: [GIT PULL for-4.4 06/25] net/mlx4_en: fix overflow in mlx4_en_init_timestamp()
Date: Wed, 11 Oct 2017 00:45:40 +0000 [thread overview]
Message-ID: <20171011004533.8044-7-alexander.levin@verizon.com> (raw)
In-Reply-To: <20171011004533.8044-1-alexander.levin@verizon.com>
From: Eric Dumazet <edumazet@google.com>
[ Upstream commit 47d3a07528ecbbccf53bc4390d70b4e3d1c04fcf ]
The cited commit makes a great job of finding optimal shift/multiplier
values assuming a 10 seconds wrap around, but forgot to change the
overflow_period computation.
It overflows in cyclecounter_cyc2ns(), and the final result is 804 ms,
which is silly.
Lets simply use 5 seconds, no need to recompute this, given how it is
supposed to work.
Later, we will use a timer instead of a work queue, since the new RX
allocation schem will no longer need mlx4_en_recover_from_oom() and the
service_task firing every 250 ms.
Fixes: 31c128b66e5b ("net/mlx4_en: Choose time-stamping shift value according to HW frequency")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Tariq Toukan <tariqt@mellanox.com>
Cc: Eugenia Emantayev <eugenia@mellanox.com>
Reviewed-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
---
drivers/net/ethernet/mellanox/mlx4/en_clock.c | 18 ++++++++----------
drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 1 -
2 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_clock.c b/drivers/net/ethernet/mellanox/mlx4/en_clock.c
index 1494997c4f7e..4dccf7287f0f 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_clock.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_clock.c
@@ -88,10 +88,17 @@ void mlx4_en_remove_timestamp(struct mlx4_en_dev *mdev)
}
}
+#define MLX4_EN_WRAP_AROUND_SEC 10UL
+/* By scheduling the overflow check every 5 seconds, we have a reasonably
+ * good chance we wont miss a wrap around.
+ * TOTO: Use a timer instead of a work queue to increase the guarantee.
+ */
+#define MLX4_EN_OVERFLOW_PERIOD (MLX4_EN_WRAP_AROUND_SEC * HZ / 2)
+
void mlx4_en_ptp_overflow_check(struct mlx4_en_dev *mdev)
{
bool timeout = time_is_before_jiffies(mdev->last_overflow_check +
- mdev->overflow_period);
+ MLX4_EN_OVERFLOW_PERIOD);
unsigned long flags;
if (timeout) {
@@ -236,7 +243,6 @@ static const struct ptp_clock_info mlx4_en_ptp_clock_info = {
.enable = mlx4_en_phc_enable,
};
-#define MLX4_EN_WRAP_AROUND_SEC 10ULL
/* This function calculates the max shift that enables the user range
* of MLX4_EN_WRAP_AROUND_SEC values in the cycles register.
@@ -258,7 +264,6 @@ void mlx4_en_init_timestamp(struct mlx4_en_dev *mdev)
{
struct mlx4_dev *dev = mdev->dev;
unsigned long flags;
- u64 ns, zero = 0;
/* mlx4_en_init_timestamp is called for each netdev.
* mdev->ptp_clock is common for all ports, skip initialization if
@@ -282,13 +287,6 @@ void mlx4_en_init_timestamp(struct mlx4_en_dev *mdev)
ktime_to_ns(ktime_get_real()));
write_unlock_irqrestore(&mdev->clock_lock, flags);
- /* Calculate period in seconds to call the overflow watchdog - to make
- * sure counter is checked at least once every wrap around.
- */
- ns = cyclecounter_cyc2ns(&mdev->cycles, mdev->cycles.mask, zero, &zero);
- do_div(ns, NSEC_PER_SEC / 2 / HZ);
- mdev->overflow_period = ns;
-
/* Configure the PHC */
mdev->ptp_clock_info = mlx4_en_ptp_clock_info;
snprintf(mdev->ptp_clock_info.name, 16, "mlx4 ptp");
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
index c41f15102ae0..10aa6544cf4d 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h
@@ -409,7 +409,6 @@ struct mlx4_en_dev {
struct cyclecounter cycles;
struct timecounter clock;
unsigned long last_overflow_check;
- unsigned long overflow_period;
struct ptp_clock *ptp_clock;
struct ptp_clock_info ptp_clock_info;
struct notifier_block nb;
--
2.11.0
next prev parent reply other threads:[~2017-10-11 0:46 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-11 0:45 [GIT PULL for-4.4 00/25] Commits for v4.4 LTS Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` [GIT PULL for-4.4 01/25] locking/lockdep: Add nest_lock integrity test Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` [GIT PULL for-4.4 05/25] mac80211: fix power saving clients handling in iwlwifi Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` [GIT PULL for-4.4 04/25] mac80211_hwsim: check HWSIM_ATTR_RADIO_NAME length Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` [GIT PULL for-4.4 03/25] irqchip/crossbar: Fix incorrect type of local variables Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` [GIT PULL for-4.4 02/25] watchdog: kempld: fix gcc-4.3 build Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` [GIT PULL for-4.4 10/25] f2fs: do not wait for writeback in write_begin Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` [GIT PULL for-4.4 08/25] iio: adc: xilinx: Fix error handling Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` [GIT PULL for-4.4 07/25] netfilter: nf_ct_expect: Change __nf_ct_expect_check() return value Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` Levin, Alexander (Sasha Levin) [this message]
2017-10-11 0:45 ` [GIT PULL for-4.4 09/25] Btrfs: send, fix failure to rename top level inode due to name collision Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` [GIT PULL for-4.4 11/25] md/linear: shutup lockdep warnning Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` [GIT PULL for-4.4 12/25] sparc64: Migrate hvcons irq to panicked cpu Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` [GIT PULL for-4.4 13/25] net/mlx4_core: Fix VF overwrite of module param which disables DMFS on new probed PFs Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` [GIT PULL for-4.4 14/25] crypto: xts - Add ECB dependency Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` [GIT PULL for-4.4 16/25] slub: do not merge cache if slub_debug contains a never-merge flag Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` [GIT PULL for-4.4 17/25] scsi: scsi_dh_emc: return success in clariion_std_inquiry() Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` [GIT PULL for-4.4 18/25] net: mvpp2: release reference to txq_cpu[] entry after unmapping Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` [GIT PULL for-4.4 15/25] ocfs2/dlmglue: prepare tracking logic to avoid recursive cluster lock Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` [GIT PULL for-4.4 21/25] uapi: fix linux/rds.h userspace compilation errors Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` [GIT PULL for-4.4 19/25] i2c: at91: ensure state is restored after suspending Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` [GIT PULL for-4.4 22/25] uapi: fix linux/mroute6.h userspace compilation errors Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` [GIT PULL for-4.4 20/25] ceph: clean up unsafe d_parent accesses in build_dentry_path Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` [GIT PULL for-4.4 25/25] cpufreq: CPPC: add ACPI_PROCESSOR dependency Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` [GIT PULL for-4.4 23/25] target/iscsi: Fix unsolicited data seq_end_offset calculation Levin, Alexander (Sasha Levin)
2017-10-11 0:45 ` [GIT PULL for-4.4 24/25] nfsd/callback: Cleanup callback cred on shutdown Levin, Alexander (Sasha Levin)
2017-10-19 13:20 ` [GIT PULL for-4.4 00/25] Commits for v4.4 LTS gregkh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171011004533.8044-7-alexander.levin@verizon.com \
--to=alexander.levin@verizon.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®