blob: 07eb949907ea97db0cce0295f71c405ebd2f6472 [file] [log] [blame]
Chong Zhang6d58e4b2020-03-31 09:41:10 -07001/*
2 * Copyright (C) 2020 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Chong Zhangacb33502020-04-20 11:04:48 -070017//#define LOG_NDEBUG 0
Chong Zhang6d58e4b2020-03-31 09:41:10 -070018#define LOG_TAG "TranscodingJobScheduler"
19
20#define VALIDATE_STATE 1
21
22#include <inttypes.h>
23#include <media/TranscodingJobScheduler.h>
24#include <utils/Log.h>
25
26#include <utility>
27
28namespace android {
29
Chong Zhang15c192a2020-05-05 16:24:00 -070030static_assert((JobIdType)-1 < 0, "JobIdType should be signed");
31
Chong Zhang7ae4e2f2020-04-17 15:24:34 -070032constexpr static uid_t OFFLINE_UID = -1;
Chong Zhang6d58e4b2020-03-31 09:41:10 -070033
34//static
35String8 TranscodingJobScheduler::jobToString(const JobKeyType& jobKey) {
36 return String8::format("{client:%lld, job:%d}", (long long)jobKey.first, jobKey.second);
37}
38
39TranscodingJobScheduler::TranscodingJobScheduler(
40 const std::shared_ptr<TranscoderInterface>& transcoder,
Chong Zhang7ae4e2f2020-04-17 15:24:34 -070041 const std::shared_ptr<UidPolicyInterface>& uidPolicy)
42 : mTranscoder(transcoder), mUidPolicy(uidPolicy), mCurrentJob(nullptr), mResourceLost(false) {
Chong Zhang6d58e4b2020-03-31 09:41:10 -070043 // Only push empty offline queue initially. Realtime queues are added when requests come in.
Chong Zhang7ae4e2f2020-04-17 15:24:34 -070044 mUidSortedList.push_back(OFFLINE_UID);
45 mOfflineUidIterator = mUidSortedList.begin();
46 mJobQueues.emplace(OFFLINE_UID, JobQueueType());
Chong Zhang6d58e4b2020-03-31 09:41:10 -070047}
48
49TranscodingJobScheduler::~TranscodingJobScheduler() {}
50
51TranscodingJobScheduler::Job* TranscodingJobScheduler::getTopJob_l() {
52 if (mJobMap.empty()) {
53 return nullptr;
54 }
Chong Zhang7ae4e2f2020-04-17 15:24:34 -070055 uid_t topUid = *mUidSortedList.begin();
56 JobKeyType topJobKey = *mJobQueues[topUid].begin();
Chong Zhang6d58e4b2020-03-31 09:41:10 -070057 return &mJobMap[topJobKey];
58}
59
60void TranscodingJobScheduler::updateCurrentJob_l() {
61 Job* topJob = getTopJob_l();
62 Job* curJob = mCurrentJob;
63 ALOGV("updateCurrentJob: topJob is %s, curJob is %s",
64 topJob == nullptr ? "null" : jobToString(topJob->key).c_str(),
65 curJob == nullptr ? "null" : jobToString(curJob->key).c_str());
66
67 // If we found a topJob that should be run, and it's not already running,
68 // take some actions to ensure it's running.
69 if (topJob != nullptr && (topJob != curJob || topJob->state != Job::RUNNING)) {
70 // If another job is currently running, pause it first.
71 if (curJob != nullptr && curJob->state == Job::RUNNING) {
72 mTranscoder->pause(curJob->key.first, curJob->key.second);
73 curJob->state = Job::PAUSED;
74 }
75 // If we are not experiencing resource loss, we can start or resume
76 // the topJob now.
77 if (!mResourceLost) {
78 if (topJob->state == Job::NOT_STARTED) {
Chong Zhang66469272020-06-04 16:51:55 -070079 mTranscoder->start(topJob->key.first, topJob->key.second, topJob->request,
80 topJob->callback.lock());
Chong Zhang6d58e4b2020-03-31 09:41:10 -070081 } else if (topJob->state == Job::PAUSED) {
82 mTranscoder->resume(topJob->key.first, topJob->key.second);
83 }
84 topJob->state = Job::RUNNING;
85 }
86 }
87 mCurrentJob = topJob;
88}
89
90void TranscodingJobScheduler::removeJob_l(const JobKeyType& jobKey) {
91 ALOGV("%s: job %s", __FUNCTION__, jobToString(jobKey).c_str());
92
93 if (mJobMap.count(jobKey) == 0) {
94 ALOGE("job %s doesn't exist", jobToString(jobKey).c_str());
95 return;
96 }
97
Chong Zhang7ae4e2f2020-04-17 15:24:34 -070098 // Remove job from uid's queue.
99 const uid_t uid = mJobMap[jobKey].uid;
100 JobQueueType& jobQueue = mJobQueues[uid];
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700101 auto it = std::find(jobQueue.begin(), jobQueue.end(), jobKey);
102 if (it == jobQueue.end()) {
Chong Zhang7ae4e2f2020-04-17 15:24:34 -0700103 ALOGE("couldn't find job %s in queue for uid %d", jobToString(jobKey).c_str(), uid);
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700104 return;
105 }
106 jobQueue.erase(it);
107
Chong Zhang7ae4e2f2020-04-17 15:24:34 -0700108 // If this is the last job in a real-time queue, remove this uid's queue.
109 if (uid != OFFLINE_UID && jobQueue.empty()) {
110 mUidSortedList.remove(uid);
111 mJobQueues.erase(uid);
Chong Zhangacb33502020-04-20 11:04:48 -0700112 mUidPolicy->unregisterMonitorUid(uid);
113
114 std::unordered_set<uid_t> topUids = mUidPolicy->getTopUids();
115 moveUidsToTop_l(topUids, false /*preserveTopUid*/);
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700116 }
117
118 // Clear current job.
119 if (mCurrentJob == &mJobMap[jobKey]) {
120 mCurrentJob = nullptr;
121 }
122
123 // Remove job from job map.
124 mJobMap.erase(jobKey);
125}
126
Chong Zhangacb33502020-04-20 11:04:48 -0700127/**
128 * Moves the set of uids to the front of mUidSortedList (which is used to pick
129 * the next job to run).
130 *
131 * This is called when 1) we received a onTopUidsChanged() callbcak from UidPolicy,
132 * or 2) we removed the job queue for a uid because it becomes empty.
133 *
134 * In case of 1), if there are multiple uids in the set, and the current front
135 * uid in mUidSortedList is still in the set, we try to keep that uid at front
136 * so that current job run is not interrupted. (This is not a concern for case 2)
137 * because the queue for a uid was just removed entirely.)
138 */
139void TranscodingJobScheduler::moveUidsToTop_l(const std::unordered_set<uid_t>& uids,
140 bool preserveTopUid) {
141 // If uid set is empty, nothing to do. Do not change the queue status.
142 if (uids.empty()) {
143 return;
144 }
145
146 // Save the current top uid.
147 uid_t curTopUid = *mUidSortedList.begin();
148 bool pushCurTopToFront = false;
149 int32_t numUidsMoved = 0;
150
151 // Go through the sorted uid list once, and move the ones in top set to front.
152 for (auto it = mUidSortedList.begin(); it != mUidSortedList.end();) {
153 uid_t uid = *it;
154
155 if (uid != OFFLINE_UID && uids.count(uid) > 0) {
156 it = mUidSortedList.erase(it);
157
158 // If this is the top we're preserving, don't push it here, push
159 // it after the for-loop.
160 if (uid == curTopUid && preserveTopUid) {
161 pushCurTopToFront = true;
162 } else {
163 mUidSortedList.push_front(uid);
164 }
165
166 // If we found all uids in the set, break out.
167 if (++numUidsMoved == uids.size()) {
168 break;
169 }
170 } else {
171 ++it;
172 }
173 }
174
175 if (pushCurTopToFront) {
176 mUidSortedList.push_front(curTopUid);
177 }
178}
179
Chong Zhang3fa408f2020-04-30 11:04:28 -0700180bool TranscodingJobScheduler::submit(ClientIdType clientId, JobIdType jobId, uid_t uid,
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700181 const TranscodingRequestParcel& request,
182 const std::weak_ptr<ITranscodingClientCallback>& callback) {
183 JobKeyType jobKey = std::make_pair(clientId, jobId);
184
Chong Zhang7ae4e2f2020-04-17 15:24:34 -0700185 ALOGV("%s: job %s, uid %d, prioirty %d", __FUNCTION__, jobToString(jobKey).c_str(), uid,
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700186 (int32_t)request.priority);
187
188 std::scoped_lock lock{mLock};
189
190 if (mJobMap.count(jobKey) > 0) {
191 ALOGE("job %s already exists", jobToString(jobKey).c_str());
192 return false;
193 }
194
195 // TODO(chz): only support offline vs real-time for now. All kUnspecified jobs
196 // go to offline queue.
197 if (request.priority == TranscodingJobPriority::kUnspecified) {
Chong Zhang7ae4e2f2020-04-17 15:24:34 -0700198 uid = OFFLINE_UID;
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700199 }
200
201 // Add job to job map.
202 mJobMap[jobKey].key = jobKey;
Chong Zhang7ae4e2f2020-04-17 15:24:34 -0700203 mJobMap[jobKey].uid = uid;
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700204 mJobMap[jobKey].state = Job::NOT_STARTED;
205 mJobMap[jobKey].request = request;
206 mJobMap[jobKey].callback = callback;
207
208 // If it's an offline job, the queue was already added in constructor.
Chong Zhang7ae4e2f2020-04-17 15:24:34 -0700209 // If it's a real-time jobs, check if a queue is already present for the uid,
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700210 // and add a new queue if needed.
Chong Zhang7ae4e2f2020-04-17 15:24:34 -0700211 if (uid != OFFLINE_UID) {
212 if (mJobQueues.count(uid) == 0) {
Chong Zhangacb33502020-04-20 11:04:48 -0700213 mUidPolicy->registerMonitorUid(uid);
Chong Zhang7ae4e2f2020-04-17 15:24:34 -0700214 if (mUidPolicy->isUidOnTop(uid)) {
215 mUidSortedList.push_front(uid);
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700216 } else {
217 // Shouldn't be submitting real-time requests from non-top app,
218 // put it in front of the offline queue.
Chong Zhang7ae4e2f2020-04-17 15:24:34 -0700219 mUidSortedList.insert(mOfflineUidIterator, uid);
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700220 }
Chong Zhang7ae4e2f2020-04-17 15:24:34 -0700221 } else if (uid != *mUidSortedList.begin()) {
222 if (mUidPolicy->isUidOnTop(uid)) {
223 mUidSortedList.remove(uid);
224 mUidSortedList.push_front(uid);
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700225 }
226 }
227 }
Chong Zhang7ae4e2f2020-04-17 15:24:34 -0700228 // Append this job to the uid's queue.
229 mJobQueues[uid].push_back(jobKey);
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700230
231 updateCurrentJob_l();
232
233 validateState_l();
234 return true;
235}
236
Chong Zhang3fa408f2020-04-30 11:04:28 -0700237bool TranscodingJobScheduler::cancel(ClientIdType clientId, JobIdType jobId) {
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700238 JobKeyType jobKey = std::make_pair(clientId, jobId);
239
240 ALOGV("%s: job %s", __FUNCTION__, jobToString(jobKey).c_str());
241
Chong Zhang15c192a2020-05-05 16:24:00 -0700242 std::list<JobKeyType> jobsToRemove;
243
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700244 std::scoped_lock lock{mLock};
245
Chong Zhang15c192a2020-05-05 16:24:00 -0700246 if (jobId < 0) {
247 for (auto it = mJobMap.begin(); it != mJobMap.end(); ++it) {
248 if (it->first.first == clientId && it->second.uid != OFFLINE_UID) {
249 jobsToRemove.push_back(it->first);
250 }
251 }
252 } else {
253 if (mJobMap.count(jobKey) == 0) {
254 ALOGE("job %s doesn't exist", jobToString(jobKey).c_str());
255 return false;
256 }
257 jobsToRemove.push_back(jobKey);
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700258 }
259
Chong Zhang15c192a2020-05-05 16:24:00 -0700260 for (auto it = jobsToRemove.begin(); it != jobsToRemove.end(); ++it) {
Chong Zhang00feca22020-05-08 15:02:06 -0700261 // If the job has ever been started, stop it now.
262 // Note that stop() is needed even if the job is currently paused. This instructs
263 // the transcoder to discard any states for the job, otherwise the states may
264 // never be discarded.
265 if (mJobMap[*it].state != Job::NOT_STARTED) {
266 mTranscoder->stop(it->first, it->second);
Chong Zhang15c192a2020-05-05 16:24:00 -0700267 }
268
269 // Remove the job.
270 removeJob_l(*it);
271 }
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700272
273 // Start next job.
274 updateCurrentJob_l();
275
276 validateState_l();
277 return true;
278}
279
Chong Zhang3fa408f2020-04-30 11:04:28 -0700280bool TranscodingJobScheduler::getJob(ClientIdType clientId, JobIdType jobId,
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700281 TranscodingRequestParcel* request) {
282 JobKeyType jobKey = std::make_pair(clientId, jobId);
283
284 std::scoped_lock lock{mLock};
285
286 if (mJobMap.count(jobKey) == 0) {
287 ALOGE("job %s doesn't exist", jobToString(jobKey).c_str());
288 return false;
289 }
290
291 *(TranscodingRequest*)request = mJobMap[jobKey].request;
292 return true;
293}
294
Chong Zhangde60f062020-06-11 17:05:10 -0700295void TranscodingJobScheduler::notifyClient(ClientIdType clientId, JobIdType jobId,
296 const char* reason,
297 std::function<void(const JobKeyType&)> func) {
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700298 JobKeyType jobKey = std::make_pair(clientId, jobId);
299
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700300 std::scoped_lock lock{mLock};
301
302 if (mJobMap.count(jobKey) == 0) {
Chong Zhangde60f062020-06-11 17:05:10 -0700303 ALOGW("%s: ignoring %s for job %s that doesn't exist", __FUNCTION__, reason,
304 jobToString(jobKey).c_str());
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700305 return;
306 }
307
308 // Only ignore if job was never started. In particular, propagate the status
309 // to client if the job is paused. Transcoder could have posted finish when
310 // we're pausing it, and the finish arrived after we changed current job.
311 if (mJobMap[jobKey].state == Job::NOT_STARTED) {
Chong Zhangde60f062020-06-11 17:05:10 -0700312 ALOGW("%s: ignoring %s for job %s that was never started", __FUNCTION__, reason,
313 jobToString(jobKey).c_str());
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700314 return;
315 }
316
Chong Zhangde60f062020-06-11 17:05:10 -0700317 ALOGV("%s: job %s %s", __FUNCTION__, jobToString(jobKey).c_str(), reason);
318 func(jobKey);
319}
320
321void TranscodingJobScheduler::onStarted(ClientIdType clientId, JobIdType jobId) {
322 notifyClient(clientId, jobId, "started", [=](const JobKeyType& jobKey) {
323 auto callback = mJobMap[jobKey].callback.lock();
324 if (callback != nullptr) {
325 callback->onTranscodingStarted(jobId);
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700326 }
Chong Zhangde60f062020-06-11 17:05:10 -0700327 });
328}
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700329
Chong Zhangde60f062020-06-11 17:05:10 -0700330void TranscodingJobScheduler::onPaused(ClientIdType clientId, JobIdType jobId) {
331 notifyClient(clientId, jobId, "paused", [=](const JobKeyType& jobKey) {
332 auto callback = mJobMap[jobKey].callback.lock();
333 if (callback != nullptr) {
334 callback->onTranscodingPaused(jobId);
335 }
336 });
337}
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700338
Chong Zhangde60f062020-06-11 17:05:10 -0700339void TranscodingJobScheduler::onResumed(ClientIdType clientId, JobIdType jobId) {
340 notifyClient(clientId, jobId, "resumed", [=](const JobKeyType& jobKey) {
341 auto callback = mJobMap[jobKey].callback.lock();
342 if (callback != nullptr) {
343 callback->onTranscodingResumed(jobId);
344 }
345 });
346}
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700347
Chong Zhangde60f062020-06-11 17:05:10 -0700348void TranscodingJobScheduler::onFinish(ClientIdType clientId, JobIdType jobId) {
349 notifyClient(clientId, jobId, "finish", [=](const JobKeyType& jobKey) {
350 {
351 auto clientCallback = mJobMap[jobKey].callback.lock();
352 if (clientCallback != nullptr) {
Chong Zhang66469272020-06-04 16:51:55 -0700353 clientCallback->onTranscodingFinished(
hkuang0bd73742020-06-24 12:57:09 -0700354 jobId, TranscodingResultParcel({jobId, -1 /*actualBitrateBps*/,
355 std::nullopt /*jobStats*/}));
Chong Zhangde60f062020-06-11 17:05:10 -0700356 }
357 }
358
359 // Remove the job.
360 removeJob_l(jobKey);
361
362 // Start next job.
363 updateCurrentJob_l();
364
365 validateState_l();
366 });
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700367}
368
Chong Zhang3fa408f2020-04-30 11:04:28 -0700369void TranscodingJobScheduler::onError(ClientIdType clientId, JobIdType jobId,
370 TranscodingErrorCode err) {
Chong Zhangde60f062020-06-11 17:05:10 -0700371 notifyClient(clientId, jobId, "error", [=](const JobKeyType& jobKey) {
372 {
373 auto clientCallback = mJobMap[jobKey].callback.lock();
374 if (clientCallback != nullptr) {
375 clientCallback->onTranscodingFailed(jobId, err);
376 }
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700377 }
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700378
Chong Zhangde60f062020-06-11 17:05:10 -0700379 // Remove the job.
380 removeJob_l(jobKey);
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700381
Chong Zhangde60f062020-06-11 17:05:10 -0700382 // Start next job.
383 updateCurrentJob_l();
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700384
Chong Zhangde60f062020-06-11 17:05:10 -0700385 validateState_l();
386 });
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700387}
388
Chong Zhang3fa408f2020-04-30 11:04:28 -0700389void TranscodingJobScheduler::onProgressUpdate(ClientIdType clientId, JobIdType jobId,
390 int32_t progress) {
Chong Zhangde60f062020-06-11 17:05:10 -0700391 notifyClient(clientId, jobId, "progress", [=](const JobKeyType& jobKey) {
392 auto callback = mJobMap[jobKey].callback.lock();
393 if (callback != nullptr) {
394 callback->onProgressUpdate(jobId, progress);
Chong Zhangacb33502020-04-20 11:04:48 -0700395 }
Chong Zhangde60f062020-06-11 17:05:10 -0700396 });
Chong Zhangacb33502020-04-20 11:04:48 -0700397}
398
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700399void TranscodingJobScheduler::onResourceLost() {
400 ALOGV("%s", __FUNCTION__);
401
402 std::scoped_lock lock{mLock};
403
404 // If we receive a resource loss event, the TranscoderLibrary already paused
405 // the transcoding, so we don't need to call onPaused to notify it to pause.
406 // Only need to update the job state here.
407 if (mCurrentJob != nullptr && mCurrentJob->state == Job::RUNNING) {
408 mCurrentJob->state = Job::PAUSED;
409 }
410 mResourceLost = true;
411
412 validateState_l();
413}
414
Chong Zhangacb33502020-04-20 11:04:48 -0700415void TranscodingJobScheduler::onTopUidsChanged(const std::unordered_set<uid_t>& uids) {
416 if (uids.empty()) {
417 ALOGW("%s: ignoring empty uids", __FUNCTION__);
418 return;
419 }
420
421 std::string uidStr;
422 for (auto it = uids.begin(); it != uids.end(); it++) {
423 if (!uidStr.empty()) {
424 uidStr += ", ";
425 }
426 uidStr += std::to_string(*it);
427 }
428
429 ALOGD("%s: topUids: size %zu, uids: %s", __FUNCTION__, uids.size(), uidStr.c_str());
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700430
431 std::scoped_lock lock{mLock};
432
Chong Zhangacb33502020-04-20 11:04:48 -0700433 moveUidsToTop_l(uids, true /*preserveTopUid*/);
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700434
435 updateCurrentJob_l();
436
437 validateState_l();
438}
439
440void TranscodingJobScheduler::onResourceAvailable() {
441 ALOGV("%s", __FUNCTION__);
442
443 std::scoped_lock lock{mLock};
444
445 mResourceLost = false;
446 updateCurrentJob_l();
447
448 validateState_l();
449}
450
451void TranscodingJobScheduler::validateState_l() {
452#ifdef VALIDATE_STATE
Chong Zhang7ae4e2f2020-04-17 15:24:34 -0700453 LOG_ALWAYS_FATAL_IF(mJobQueues.count(OFFLINE_UID) != 1,
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700454 "mJobQueues offline queue number is not 1");
Chong Zhang7ae4e2f2020-04-17 15:24:34 -0700455 LOG_ALWAYS_FATAL_IF(*mOfflineUidIterator != OFFLINE_UID,
456 "mOfflineUidIterator not pointing to offline uid");
457 LOG_ALWAYS_FATAL_IF(mUidSortedList.size() != mJobQueues.size(),
458 "mUidList and mJobQueues size mismatch");
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700459
460 int32_t totalJobs = 0;
Chong Zhang7ae4e2f2020-04-17 15:24:34 -0700461 for (auto uidIt = mUidSortedList.begin(); uidIt != mUidSortedList.end(); uidIt++) {
462 LOG_ALWAYS_FATAL_IF(mJobQueues.count(*uidIt) != 1, "mJobQueues count for uid %d is not 1",
463 *uidIt);
464 for (auto jobIt = mJobQueues[*uidIt].begin(); jobIt != mJobQueues[*uidIt].end(); jobIt++) {
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700465 LOG_ALWAYS_FATAL_IF(mJobMap.count(*jobIt) != 1, "mJobs count for job %s is not 1",
466 jobToString(*jobIt).c_str());
467 }
468
Chong Zhang7ae4e2f2020-04-17 15:24:34 -0700469 totalJobs += mJobQueues[*uidIt].size();
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700470 }
471 LOG_ALWAYS_FATAL_IF(mJobMap.size() != totalJobs,
Chong Zhang7ae4e2f2020-04-17 15:24:34 -0700472 "mJobs size doesn't match total jobs counted from uid queues");
Chong Zhang6d58e4b2020-03-31 09:41:10 -0700473#endif // VALIDATE_STATE
474}
475
476} // namespace android