Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 22 Feb 2021 23:56:48 GMT
From:      Navdeep Parhar <np@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: ab88a1ff14ef - stable/12 - cxgbe(4): Save proper zone index on low memory in refill_fl().
Message-ID:  <202102222356.11MNum8a010599@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by np:

URL: https://cgit.FreeBSD.org/src/commit/?id=ab88a1ff14ef1db0296af1d2be648b784ba4e614

commit ab88a1ff14ef1db0296af1d2be648b784ba4e614
Author:     Alexander Motin <mav@FreeBSD.org>
AuthorDate: 2021-02-17 02:15:28 +0000
Commit:     Navdeep Parhar <np@FreeBSD.org>
CommitDate: 2021-02-22 23:55:19 +0000

    cxgbe(4): Save proper zone index on low memory in refill_fl().
    
    When refill_fl() fails to allocate large (9/16KB) mbuf cluster, it
    falls back to safe (4KB) ones.  But it still saved into sd->zidx
    the original fl->zidx instead of fl->safe_zidx.  It caused problems
    with the later use of that cluster, including memory and/or data
    corruption.
    
    While there, make refill_fl() to use the safe zone for all following
    clusters for the call, since it is unlikely that large succeed.
    
    MFC after:      3 days
    Sponsored by:   iXsystems, Inc.
    Reviewed by:    np, jhb
    Differential Revision:  https://reviews.freebsd.org/D28716
    
    (cherry picked from commit 294e62bebf36f873fd083d2fe8edd78919dda4e8)
---
 sys/dev/cxgbe/t4_sge.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c
index 335fd28644d2..4489d40e9fe4 100644
--- a/sys/dev/cxgbe/t4_sge.c
+++ b/sys/dev/cxgbe/t4_sge.c
@@ -4530,7 +4530,7 @@ refill_fl(struct adapter *sc, struct sge_fl *fl, int n)
 	caddr_t cl;
 	struct rx_buf_info *rxb;
 	struct cluster_metadata *clm;
-	uint16_t max_pidx;
+	uint16_t max_pidx, zidx = fl->zidx;
 	uint16_t hw_cidx = fl->hw_cidx;		/* stable snapshot */
 
 	FL_LOCK_ASSERT_OWNED(fl);
@@ -4546,6 +4546,7 @@ refill_fl(struct adapter *sc, struct sge_fl *fl, int n)
 
 	d = &fl->desc[fl->pidx];
 	sd = &fl->sdesc[fl->pidx];
+	rxb = &sc->sge.rx_buf_info[zidx];
 
 	while (n > 0) {
 
@@ -4579,11 +4580,11 @@ refill_fl(struct adapter *sc, struct sge_fl *fl, int n)
 			sd->cl = NULL;	/* gave up my reference */
 		}
 		MPASS(sd->cl == NULL);
-		rxb = &sc->sge.rx_buf_info[fl->zidx];
 		cl = uma_zalloc(rxb->zone, M_NOWAIT);
 		if (__predict_false(cl == NULL)) {
-			if (fl->zidx != fl->safe_zidx) {
-				rxb = &sc->sge.rx_buf_info[fl->safe_zidx];
+			if (zidx != fl->safe_zidx) {
+				zidx = fl->safe_zidx;
+				rxb = &sc->sge.rx_buf_info[zidx];
 				cl = uma_zalloc(rxb->zone, M_NOWAIT);
 			}
 			if (cl == NULL)
@@ -4594,7 +4595,7 @@ refill_fl(struct adapter *sc, struct sge_fl *fl, int n)
 
 		pa = pmap_kextract((vm_offset_t)cl);
 		sd->cl = cl;
-		sd->zidx = fl->zidx;
+		sd->zidx = zidx;
 
 		if (fl->flags & FL_BUF_PACKING) {
 			*d = htobe64(pa | rxb->hwidx2);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202102222356.11MNum8a010599>