Re: PATCH: two slab-like memory allocators - Mailing list pgsql-hackers

From Jim Nasby
Subject Re: PATCH: two slab-like memory allocators
Date
Msg-id b5d04d86-5a89-457c-e82f-c52b8ebc6be6@BlueTreble.com
Whole thread Raw
In response to Re: PATCH: two slab-like memory allocators  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
List pgsql-hackers
On 10/1/16 7:34 PM, Tomas Vondra wrote:
>> +    /* otherwise add it to the proper freelist bin */
>> Looks like something went missing... :)
>>
>
> Ummm? The patch contains this:
>
> +    /* otherwise add it to the proper freelist bin */
> +    if (set->freelist[block->nfree])
> +        set->freelist[block->nfree]->prev = block;
> +
> +    block->next = set->freelist[block->nfree];
> +    set->freelist[block->nfree] = block;
>
> Which does exactly the thing it should do. Or what is missing?

What's confusing is the "otherwise" right at the beginning of the function:

+static void
+add_to_freelist(Slab set, SlabBlock block)
+{
+    /* otherwise add it to the proper freelist bin */
+    if (set->freelist[block->nfree])
+        set->freelist[block->nfree]->prev = block;
+
+    block->next = set->freelist[block->nfree];
+    set->freelist[block->nfree] = block;
+}

Otherwise what? What's the other option?


(Haven't looked at the newer patch, so maybe this isn't an issue anymore.)
-- 
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com
855-TREBLE2 (855-873-2532)   mobile: 512-569-9461



pgsql-hackers by date:

Previous
From: David Rowley
Date:
Subject: Re: Improving RLS planning
Next
From: Jim Nasby
Date:
Subject: Re: emergency outage requiring database restart