Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd53e3d5

Browse files
committed
Remove volatile qualifiers from proc.c and procarray.c
Prior to commit0709b7e, access tovariables within a spinlock-protected critical section had to be donethrough a volatile pointer, but that should no longer be necessary.Michael Paquier
1 parent430008b commitd53e3d5

File tree

2 files changed

+19
-36
lines changed

2 files changed

+19
-36
lines changed

‎src/backend/storage/ipc/procarray.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3718,8 +3718,6 @@ static int
37183718
KnownAssignedXidsGetAndSetXmin(TransactionId*xarray,TransactionId*xmin,
37193719
TransactionIdxmax)
37203720
{
3721-
/* use volatile pointer to prevent code rearrangement */
3722-
volatileProcArrayStruct*pArray=procArray;
37233721
intcount=0;
37243722
inthead,
37253723
tail;
@@ -3734,10 +3732,10 @@ KnownAssignedXidsGetAndSetXmin(TransactionId *xarray, TransactionId *xmin,
37343732
*
37353733
* Must take spinlock to ensure we see up-to-date array contents.
37363734
*/
3737-
SpinLockAcquire(&pArray->known_assigned_xids_lck);
3738-
tail=pArray->tailKnownAssignedXids;
3739-
head=pArray->headKnownAssignedXids;
3740-
SpinLockRelease(&pArray->known_assigned_xids_lck);
3735+
SpinLockAcquire(&procArray->known_assigned_xids_lck);
3736+
tail=procArray->tailKnownAssignedXids;
3737+
head=procArray->headKnownAssignedXids;
3738+
SpinLockRelease(&procArray->known_assigned_xids_lck);
37413739

37423740
for (i=tail;i<head;i++)
37433741
{
@@ -3777,19 +3775,17 @@ KnownAssignedXidsGetAndSetXmin(TransactionId *xarray, TransactionId *xmin,
37773775
staticTransactionId
37783776
KnownAssignedXidsGetOldestXmin(void)
37793777
{
3780-
/* use volatile pointer to prevent code rearrangement */
3781-
volatileProcArrayStruct*pArray=procArray;
37823778
inthead,
37833779
tail;
37843780
inti;
37853781

37863782
/*
37873783
* Fetch head just once, since it may change while we loop.
37883784
*/
3789-
SpinLockAcquire(&pArray->known_assigned_xids_lck);
3790-
tail=pArray->tailKnownAssignedXids;
3791-
head=pArray->headKnownAssignedXids;
3792-
SpinLockRelease(&pArray->known_assigned_xids_lck);
3785+
SpinLockAcquire(&procArray->known_assigned_xids_lck);
3786+
tail=procArray->tailKnownAssignedXids;
3787+
head=procArray->headKnownAssignedXids;
3788+
SpinLockRelease(&procArray->known_assigned_xids_lck);
37933789

37943790
for (i=tail;i<head;i++)
37953791
{

‎src/backend/storage/lmgr/proc.c

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -283,27 +283,25 @@ InitProcGlobal(void)
283283
void
284284
InitProcess(void)
285285
{
286-
/* use volatile pointer to prevent code rearrangement */
287-
volatilePROC_HDR*procglobal=ProcGlobal;
288286
PGPROC*volatile*procgloballist;
289287

290288
/*
291289
* ProcGlobal should be set up already (if we are a backend, we inherit
292290
* this by fork() or EXEC_BACKEND mechanism from the postmaster).
293291
*/
294-
if (procglobal==NULL)
292+
if (ProcGlobal==NULL)
295293
elog(PANIC,"proc header uninitialized");
296294

297295
if (MyProc!=NULL)
298296
elog(ERROR,"you already exist");
299297

300298
/* Decide which list should supply our PGPROC. */
301299
if (IsAnyAutoVacuumProcess())
302-
procgloballist=&procglobal->autovacFreeProcs;
300+
procgloballist=&ProcGlobal->autovacFreeProcs;
303301
elseif (IsBackgroundWorker)
304-
procgloballist=&procglobal->bgworkerFreeProcs;
302+
procgloballist=&ProcGlobal->bgworkerFreeProcs;
305303
else
306-
procgloballist=&procglobal->freeProcs;
304+
procgloballist=&ProcGlobal->freeProcs;
307305

308306
/*
309307
* Try to get a proc struct from the appropriate free list. If this
@@ -314,7 +312,7 @@ InitProcess(void)
314312
*/
315313
SpinLockAcquire(ProcStructLock);
316314

317-
set_spins_per_delay(procglobal->spins_per_delay);
315+
set_spins_per_delay(ProcGlobal->spins_per_delay);
318316

319317
MyProc=*procgloballist;
320318

@@ -578,13 +576,10 @@ InitAuxiliaryProcess(void)
578576
void
579577
PublishStartupProcessInformation(void)
580578
{
581-
/* use volatile pointer to prevent code rearrangement */
582-
volatilePROC_HDR*procglobal=ProcGlobal;
583-
584579
SpinLockAcquire(ProcStructLock);
585580

586-
procglobal->startupProc=MyProc;
587-
procglobal->startupProcPid=MyProcPid;
581+
ProcGlobal->startupProc=MyProc;
582+
ProcGlobal->startupProcPid=MyProcPid;
588583

589584
SpinLockRelease(ProcStructLock);
590585
}
@@ -627,12 +622,9 @@ HaveNFreeProcs(int n)
627622
{
628623
PGPROC*proc;
629624

630-
/* use volatile pointer to prevent code rearrangement */
631-
volatilePROC_HDR*procglobal=ProcGlobal;
632-
633625
SpinLockAcquire(ProcStructLock);
634626

635-
proc=procglobal->freeProcs;
627+
proc=ProcGlobal->freeProcs;
636628

637629
while (n>0&&proc!=NULL)
638630
{
@@ -772,8 +764,6 @@ RemoveProcFromArray(int code, Datum arg)
772764
staticvoid
773765
ProcKill(intcode,Datumarg)
774766
{
775-
/* use volatile pointer to prevent code rearrangement */
776-
volatilePROC_HDR*procglobal=ProcGlobal;
777767
PGPROC*proc;
778768
PGPROC*volatile*procgloballist;
779769

@@ -822,7 +812,7 @@ ProcKill(int code, Datum arg)
822812
*procgloballist=proc;
823813

824814
/* Update shared estimate of spins_per_delay */
825-
procglobal->spins_per_delay=update_spins_per_delay(procglobal->spins_per_delay);
815+
ProcGlobal->spins_per_delay=update_spins_per_delay(ProcGlobal->spins_per_delay);
826816

827817
SpinLockRelease(ProcStructLock);
828818

@@ -1644,9 +1634,6 @@ ProcSendSignal(int pid)
16441634

16451635
if (RecoveryInProgress())
16461636
{
1647-
/* use volatile pointer to prevent code rearrangement */
1648-
volatilePROC_HDR*procglobal=ProcGlobal;
1649-
16501637
SpinLockAcquire(ProcStructLock);
16511638

16521639
/*
@@ -1657,8 +1644,8 @@ ProcSendSignal(int pid)
16571644
* backend, so BackendPidGetProc() will not return any pid at all. So
16581645
* we remember the information for this special case.
16591646
*/
1660-
if (pid==procglobal->startupProcPid)
1661-
proc=procglobal->startupProc;
1647+
if (pid==ProcGlobal->startupProcPid)
1648+
proc=ProcGlobal->startupProc;
16621649

16631650
SpinLockRelease(ProcStructLock);
16641651
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp