Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ea765431 authored by Manoj N. Kumar's avatar Manoj N. Kumar Committed by Martin K. Petersen
Browse files

cxlflash: Move to exponential back-off when cmd_room is not available



While profiling the cxlflash_queuecommand() path under a heavy load it
was found that number of retries to find cmd_room was fairly high.

There are two problems with the current back-off:
a) It starts with a udelay of 0
b) It backs-off linearly

Tried several approaches (a higher multiple 10*n, 100*n, as well as n^2,
2^n) and found that the exponential back-off(2^n) approach had the least
overall cost. Cost as being defined as overall time spent waiting.

The fix is to change the linear back-off to an exponential back-off.
This solution also takes care of the problem with the initial
delay (starts with 1 usec).

Signed-off-by: default avatarManoj N. Kumar <manoj@linux.vnet.ibm.com>
Acked-by: default avatarMatthew R. Ochs <mrochs@linux.vnet.ibm.com>
Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: default avatarUma Krishnan <ukrishn@linux.vnet.ibm.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 9526f360
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -289,7 +289,7 @@ static void context_reset(struct afu_cmd *cmd)
		atomic64_set(&afu->room, room);
		if (room)
			goto write_rrin;
		udelay(nretry);
		udelay(1 << nretry);
	} while (nretry++ < MC_ROOM_RETRY_CNT);

	pr_err("%s: no cmd_room to send reset\n", __func__);
@@ -303,7 +303,7 @@ static void context_reset(struct afu_cmd *cmd)
		if (rrin != 0x1)
			break;
		/* Double delay each time */
		udelay(2 << nretry);
		udelay(1 << nretry);
	} while (nretry++ < MC_ROOM_RETRY_CNT);
}

@@ -338,7 +338,7 @@ static int send_cmd(struct afu *afu, struct afu_cmd *cmd)
			atomic64_set(&afu->room, room);
			if (room)
				goto write_ioarrin;
			udelay(nretry);
			udelay(1 << nretry);
		} while (nretry++ < MC_ROOM_RETRY_CNT);

		dev_err(dev, "%s: no cmd_room to send 0x%X\n",
@@ -352,7 +352,7 @@ static int send_cmd(struct afu *afu, struct afu_cmd *cmd)
		 * afu->room.
		 */
		if (nretry++ < MC_ROOM_RETRY_CNT) {
			udelay(nretry);
			udelay(1 << nretry);
			goto retry;
		}