std::vector<computed_hash_values> hash_values (mcount);
 
       msymbols = m_objfile->per_bfd->msymbols.get ();
-      gdb::parallel_for_each
-       (&msymbols[0], &msymbols[mcount],
+      /* Arbitrarily require at least 10 elements in a thread.  */
+      gdb::parallel_for_each (10, &msymbols[0], &msymbols[mcount],
         [&] (minimal_symbol *start, minimal_symbol *end)
         {
           for (minimal_symbol *msym = start; msym < end; ++msym)
 
 
    This approach was chosen over having the callback work on single
    items because it makes it simple for the caller to do
-   once-per-subrange initialization and destruction.  */
+   once-per-subrange initialization and destruction.
+
+   The parameter N says how batching ought to be done -- there will be
+   at least N elements processed per thread.  Setting N to 0 is not
+   allowed.  */
 
 template<class RandomIt, class RangeFunction>
 void
-parallel_for_each (RandomIt first, RandomIt last, RangeFunction callback)
+parallel_for_each (unsigned n, RandomIt first, RandomIt last,
+                  RangeFunction callback)
 {
   /* So we can use a local array below.  */
   const size_t local_max = 16;
   size_t n_elements = last - first;
   if (n_threads > 1)
     {
-      /* Arbitrarily require that there should be at least 10 elements
-        in a thread.  */
-      if (n_elements / n_threads < 10)
-       n_threads = std::max (n_elements / 10, (size_t) 1);
+      /* Require that there should be at least N elements in a
+        thread.  */
+      gdb_assert (n > 0);
+      if (n_elements / n_threads < n)
+       n_threads = std::max (n_elements / n, (size_t) 1);
       size_t elts_per_thread = n_elements / n_threads;
       n_actual_threads = n_threads - 1;
       for (int i = 0; i < n_actual_threads; ++i)