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

Commit 957cc168 authored by Satya Durga Srinivasu Prabhala's avatar Satya Durga Srinivasu Prabhala
Browse files

sched: restore all values for sched_{up,down}_migrate knobs in error case



Now that the sched_{up,down}_migrate knobs accept multiple values
depends on the number of clusters in the system, if any of the up
migrate values is more than respective down migrate value, updating
sched_{up,down}_migrate knobs are aborted by restoring only first
value and returning an error to user. Instead of just restoring first
value in the vector, restore all the values in case of error.

Change-Id: If565fb951aa0c00d2dc4a8b4f1f7a90caf4d325f
Signed-off-by: default avatarSatya Durga Srinivasu Prabhala <satyap@codeaurora.org>
parent c3179e5f
Loading
Loading
Loading
Loading
+17 −7
Original line number Diff line number Diff line
@@ -6840,12 +6840,11 @@ int sched_updown_migrate_handler(struct ctl_table *table, int write,
{
	int ret, i;
	unsigned int *data = (unsigned int *)table->data;
	unsigned int old_val;
	unsigned int *old_val;
	static DEFINE_MUTEX(mutex);
	static int cap_margin_levels = -1;

	mutex_lock(&mutex);
	old_val = *data;

	if (cap_margin_levels == -1 ||
		table->maxlen != (sizeof(unsigned int) * cap_margin_levels)) {
@@ -6854,25 +6853,36 @@ int sched_updown_migrate_handler(struct ctl_table *table, int write,
	}

	if (cap_margin_levels <= 0) {
		mutex_unlock(&mutex);
		return -EINVAL;
		ret = -EINVAL;
		goto unlock_mutex;
	}

	old_val = kzalloc(table->maxlen, GFP_KERNEL);
	if (!old_val) {
		ret = -ENOMEM;
		goto unlock_mutex;
	}

	memcpy(old_val, data, table->maxlen);

	ret = proc_douintvec_capacity(table, write, buffer, lenp, ppos);

	if (!ret && write) {
		for (i = 0; i < cap_margin_levels; i++) {
			if (sysctl_sched_capacity_margin_up[i] >
					sysctl_sched_capacity_margin_down[i]) {
				*data = old_val;
				mutex_unlock(&mutex);
				return -EINVAL;
				memcpy(data, old_val, table->maxlen);
				ret = -EINVAL;
				goto free_old_val;
			}
		}

		ret = sched_update_updown_migrate_values(data,
						cap_margin_levels, ret);
	}
free_old_val:
	kfree(old_val);
unlock_mutex:
	mutex_unlock(&mutex);

	return ret;